Clear Filters
Clear Filters

How do I see all the answers of the iteration?

3 views (last 30 days)
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?

Accepted Answer

Raghava S N
Raghava S N on 19 Jun 2023
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

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!