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

3 ビュー (過去 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 件のコメント
Solarmew
Solarmew 2015 年 5 月 20 日
ah, i see, that worked! Thank you :]

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by