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'
8 件のコメント
その他の回答 (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!