Changing Structure field value from a function
古いコメントを表示
Greetings all,
I have a question regarding the Structure field value. I'm trying to change a field of my structure that is already in the workspace. as follows: mys(1).id = {100};
I can do that from the command line and the value changes, but that is not happening from inside the function. Any idea why is that ?
2 件のコメント
KSSV
2016 年 11 月 9 日
Are you sending the data which in work-space to the function? Show us your code.
MoHAJNEN komo olkm
2016 年 11 月 9 日
編集済み: MoHAJNEN komo olkm
2016 年 11 月 9 日
採用された回答
その他の回答 (1 件)
Guillaume
2016 年 11 月 9 日
0 投票
Matlab is pass-by-value. functions always receive the copy of the variable. Any change you make to variables are only local to the function unless the function also returns the variable as an output and the caller assigns that output back to the original variable.
カテゴリ
ヘルプ センター および File Exchange で Other Formats についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!