Plot from 26 by 20 matrix vs a 2D matrix

3 ビュー (過去 30 日間)
Karl Zammit
Karl Zammit 2022 年 2 月 20 日
コメント済み: Karl Zammit 2022 年 2 月 21 日
Hi, I am having trouble with plotting five figures from one 26 by 20 matrix, where the first four columns denote the y coordinates of the four lines of the first figure, the second four columns denote the y coordinates of the four lines of the secong figure, etc. However the x coordinates are stored in a 2D 26 by 5 matrix where the first column denotes the x coordinate for the first figure, the second column for the second figure, etc. I have tried something as follows:
for i5 = 0:N1:(N1*N1)
%h1 = h(:,i5+1);
%h2 = h(:,i5+2);
%h3 = h(:,i5+3);
%h4 = h(:,i5+4);
lnNu_r1 = lnNu_r(:,i5+1);
lnNu_r2 = lnNu_r(:,i5+2);
lnNu_r3 = lnNu_r(:,i5+3);
lnNu_r4 = lnNu_r(:,i5+4);
% lnNu vs lnRe for effect of Ctflow
figure(i5+2)
plot(lnRe_phi(:,i5+1),lnNu_r1,'+')
hold on
plot(lnRe_phi(:,i5+1),lnNu_r2,'+')
plot(lnRe_phi(:,i5+1),lnNu_r3,'+')
plot(lnRe_phi(:,i5+1),lnNu_r4,'+')
hold off
title('Variation of ln(Local Nusselt Number) vs ln(Local Reynolds Number)')
xlabel('ln(Re_\phi)')
ylabel('ln(Nu_r)')
legend('{C}_{{w}_{1}}','{C}_{{w}_{2}}','{C}_{{w}_{3}}','{C}_{{w}_{4}}')
grid
end
I think the issue lies about how the lnRe_phi is called but I have run out of ideas on how to do so.

採用された回答

Voss
Voss 2022 年 2 月 20 日
If I understand correctly, the column used to get the x-coordinates out of the matrix lnRe_phi, needs to be 1, 2, 3, 4, 5 when i5 is 0, 4, 8, 12, 16. If that's right, then something like this would work:
% 26-by-5 matrix of x coordinates
lnRe_phi = linspace(0,5,26).'+(0:4)
lnRe_phi = 26×5
0 1.0000 2.0000 3.0000 4.0000 0.2000 1.2000 2.2000 3.2000 4.2000 0.4000 1.4000 2.4000 3.4000 4.4000 0.6000 1.6000 2.6000 3.6000 4.6000 0.8000 1.8000 2.8000 3.8000 4.8000 1.0000 2.0000 3.0000 4.0000 5.0000 1.2000 2.2000 3.2000 4.2000 5.2000 1.4000 2.4000 3.4000 4.4000 5.4000 1.6000 2.6000 3.6000 4.6000 5.6000 1.8000 2.8000 3.8000 4.8000 5.8000
% 26-by-20 matrix of y coordinates
lnNu_r = randn(26,20);
N1 = 4;
for i5 = 0:N1:(N1*N1)
%h1 = h(:,i5+1);
%h2 = h(:,i5+2);
%h3 = h(:,i5+3);
%h4 = h(:,i5+4);
lnNu_r1 = lnNu_r(:,i5+1);
lnNu_r2 = lnNu_r(:,i5+2);
lnNu_r3 = lnNu_r(:,i5+3);
lnNu_r4 = lnNu_r(:,i5+4);
x_column = i5/N1+1;
% lnNu vs lnRe for effect of Ctflow
figure(i5+2)
plot(lnRe_phi(:,x_column),lnNu_r1,'+')
hold on
plot(lnRe_phi(:,x_column),lnNu_r2,'+')
plot(lnRe_phi(:,x_column),lnNu_r3,'+')
plot(lnRe_phi(:,x_column),lnNu_r4,'+')
hold off
title('Variation of ln(Local Nusselt Number) vs ln(Local Reynolds Number)')
xlabel('ln(Re_\phi)')
ylabel('ln(Nu_r)')
legend('{C}_{{w}_{1}}','{C}_{{w}_{2}}','{C}_{{w}_{3}}','{C}_{{w}_{4}}')
grid
end
  1 件のコメント
Karl Zammit
Karl Zammit 2022 年 2 月 21 日
Thanks a lot for your answer! Not sure how that would quite work for the i5=0 case, however looking at your results it seens as though it has.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by