How do I see all the answers of the iteration?

1 次查看(过去 30 天)
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops 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