I want my simulation/function to run n (is defined) number of times. The function is a matrix. And will give different matrices each time I run it (this is been taken care of) I just need to produce a loop which will simulate my function n ti

1 回表示 (過去 30 日間)
Neje
Neje 2018 年 3 月 26 日
回答済み: Neje 2018 年 3 月 28 日
Hello! I want my simulation/function to run n (is defined) number of times. The function is a matrix. And will give different matrices each time I run it (this is been taken care of) I just need to produce a loop which will simulate my function n times. I have the following code, which does not work.
% code
for r=1:7
y(r) = myfunction;
end
  8 件のコメント
Kai Domhardt
Kai Domhardt 2018 年 3 月 27 日

Try

temp_1 = L*x_s
temp_2 = del*c_s
temp_3 = temp_1 + temp_2
b_s = temp_3 * p_s

instead of

b_s=(L*x_s+del*c_s)*p_s

and check which line your program fails on.

Neje
Neje 2018 年 3 月 28 日
Thanks it works! :) and I could form the loop.

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

回答 (1 件)

Neje
Neje 2018 年 3 月 28 日
Just put an empty function at the start, before the function as A=[] and increment it n times with A=[A;B] after the calculation of B matrix.

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by