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')
0 个评论
采纳的回答
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'
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Migrate GUIDE Apps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!