Use a for loop to generate function arguments
古いコメントを表示
I want to use a function myfunction in a loop that can take an increasing number of arguments. I also want to save the result into a variable that each time has a different name. The result is also a vector. For example
for i=1:50
data_i=myfunction(d,d,d,...) %The number of arguments will nicrease
end
In other words I want to create this:
i=1 data_1=myfunction(d)
i=2 data_2=myfunction(d, d)
i=3 data_3=myfunction(d, d, d)
i=4 data_4=myfunction(d, d, d, d)
i=5 data_5=myfunction(d, d, d, d, d)
I found some similar questions but none of the answers were suitable.
Thanks for your help.
採用された回答
その他の回答 (1 件)
VBBV
2022 年 12 月 8 日
data_i(i)=myfunction(d,d,d,...)
3 件のコメント
VBBV
2022 年 12 月 8 日
Use for loop index
Georgios Pyrgiotakis
2022 年 12 月 8 日
VBBV
2022 年 12 月 8 日
data_i{i}=myfunction(d,d,d,...)
In that case use a cell array
カテゴリ
ヘルプ センター および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!