How could I make these functions as a loop?

Hi all, How could I make these functions as a loop? these is the functions output1=net1(Test_Inputs); output2=net2(Test_Inputs); output3=net3(Test_Inputs); output4=net4(Test_Inputs); output5=net5(Test_Inputs);

 採用された回答

MHN
MHN 2016 年 4 月 27 日

0 投票

It is not a good idea to use this kind of coding, but the following code will do what you want.
for i = 1:5
a = sprintf('output%d=net%d(Test_Inputs);', i,i);
eval(a)
end

2 件のコメント

mahmoud mosa
mahmoud mosa 2016 年 4 月 28 日
編集済み: mahmoud mosa 2016 年 4 月 28 日
thanks a lot, it is perfectly work. but, could i put 'i =1: n' and make it as a function of (n) according to the number of nets i have
MHN
MHN 2016 年 4 月 28 日
No problem. Sure, you can do it.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

質問済み:

2016 年 4 月 27 日

コメント済み:

MHN
2016 年 4 月 28 日

Community Treasure Hunt

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

Start Hunting!

Translated by