How to make function assign variables that will stick around after the function is done running?

1 次查看(过去 30 天)
For example:
function test(x)
car.color = x;
end
if i first input
global car
I want car.color to exist after i input test('red')

采纳的回答

Star Strider
Star Strider 2015-5-20
Have it return the structure ‘car’ as an output:
function car = test(x)
car.color = x;
end
%
car = test('red')
produces:
car =
color: 'red'
  8 个评论

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by