How do I see all the answers of the iteration?

1 回表示 (過去 30 日間)
Eleanor McCabe
Eleanor McCabe 2023 年 6 月 19 日
コメント済み: Eleanor McCabe 2023 年 6 月 19 日
I'm trying to see the difference in output for varying Tj values.
I get the final output, but I would like to see all of the outputs corresponding to the different Tj values.
How do I got about this?

採用された回答

Raghava S N
Raghava S N 2023 年 6 月 19 日
Move the constants out of the loop. Then, see what variables depend on Tj and put them in the loop. Assuming you want to find the value of renergyfromreactor for each value of Tj, put the evaluation statement as well in the loop. Declare the result as an array of zeros. Keep a loop counter, say k to make entries into the result array. Each time in the loop, evaluate for that Tj and write into the output array. Hope this helps!
function [renergyfrom reactor, list_of_Tjs] = Radiant_Energy_From_Reactor_Surface(Ai, Ei, Viewfactorij, Ti, Tj);
Ri = 0.22;
Rj = 0.1;
H = 0.197;
Ai = pi*Ri^2;
Aj = pi*Rj^2;
Ti = 900;
Tj = 600;
Zz = Ti^4;
Ei = 0.8;
sigma = 5.6704e-8;
Viewfactorij = 0.1088;
renergyfromreactor = zeros(1, length(10:10:70));
list_of_Tjs = zeros(1, length(10:10:70));
k = 1;
for i=10:10:70
Yy = Tj^4;
ZY = Zz-Yy;
renergyfromreactor(k) = sigma*Ai*Ei*Viewfactorij*ZY;
list_of_Tjs(k) = Tj
Tj = Tj + i;
k=k+1;
end
end
  1 件のコメント
Eleanor McCabe
Eleanor McCabe 2023 年 6 月 19 日
Amazing thank you very much!

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by