Is there a way to change the value of a variable within a function?
3 ビュー (過去 30 日間)
古いコメントを表示
Hi everyone,
I was wondering for a function with 4 arguments within it, can I change the value of 2 arguments multiple times and keep two arguments constant, and get an output for the function each time under the same set of data for output?
eg
function v=fctionname (a1,a2,a3,a4)
a1 = 2
a2 = 4
a3 = variable value (changed say 7 times)
a4 variable value (changed say 7 times)
producing
v = 7 different values
Many thanks!
採用された回答
dpb
2020 年 11 月 8 日
You can do anything you want inside the function as long as you can write a definition of what it is that is to happen.
You could pas the a3, a4 variables as arrays and use them as most transparent way but most required of user. If the initial value of a3, a4 are needed and modified, then that's easy enough, too. Or, if they are totally defined by the function, they wouldn't even need to be arguments.
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Startup and Shutdown についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!