Plot from 26 by 20 matrix vs a 2D matrix
조회 수: 1 (최근 30일)
이전 댓글 표시
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.
댓글 수: 0
채택된 답변
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)
% 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
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!