How to graph this 'for' loop

Hi there, I am having trouble graphing this for loop.
j=0;
for j = 0:1.0035
Re(j) = (30*j)/(60.21*10^-6);
Nu(j) = 0.453*((Re(j))^(1/2))*((0.690)^(1/3));
h(j) = (Nu(j)*(49.7*10^-3))/j;
T_s(j) = (q_flux/h(j)) + T_inf;
j = j+dx;
end
plot(x,Re); hold on
I keep getting the error
Array indices must be positive integers or logical values.

回答 (1 件)

Star Strider
Star Strider 2020 年 10 月 15 日

1 投票

Try something like this (with the correct variable values):
T_inf = eps; % Not Provided
q_flux = 42; % Not Provided
dx = 0.01; % Not Provided
x = 0:dx:1.0035;
for j = 1:numel(x)
Re(j) = (30*x(j))/(60.21E-6);
Nu(j) = 0.453*((Re(j))^(1/2))*((0.690)^(1/3));
h(j) = (Nu(j)*(49.7E-3))/x(j);
T_s(j) = (q_flux/h(j)) + T_inf;
end
figure
plot(x,Re)
grid
.

2 件のコメント

Zachary Lodigensky
Zachary Lodigensky 2020 年 10 月 15 日
Thank you very much!
Star Strider
Star Strider 2020 年 10 月 15 日
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.

この質問は閉じられています。

製品

リリース

R2020a

質問済み:

2020 年 10 月 15 日

閉鎖済み:

2021 年 8 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by