Plotting five figures from one 7 x 20 matrix
1 次查看(过去 30 天)
显示 更早的评论
Hi, I am having trouble with plotting five figures from one 7 by 20 matrix, where the first four columns denote the x coordinates of the four lines of the first figure, the second four columns denote the x coordinates of the four lines of the secong figure, etc. I have tried something as follows:
pstar = cell2mat(pStar);
N2 = 5;
for i5 = 0:N2:((N2*N2)-1)
pstar1 = pstar(:,i5+1);
pstar2 = pstar(:,i5+2);
pstar3 = pstar(:,i5+3);
pstar4 = pstar(:,i5+4);
end
which would give me a figure on using:
% pStar plot
figure(3)
plot(pstar1,X1,'+')
hold on
plot(pstar2,X1,'+')
plot(pstar3,X1,'+')
plot(pstar4,X1,'+')
hold off
title('Radial Distribution of Dimensionless Pressure')
xlabel('p*')
ylabel('x')
legend('{C}_{{w}_{1}}','{C}_{{w}_{2}}','{C}_{{w}_{3}}','{C}_{{w}_{4}}')
grid
where the y coordinates are: X1 = 0.4000 0.5000 0.6000 0.7000 0.8000 0.9000 1.0000 , corresponding to each of the seven rows, and the matrix:
pstar =
Columns 1 through 11
-0.0230 -0.0222 -0.0188 -0.0162 -0.0232 -0.0228 -0.0213 -0.0202 -0.0232 -0.0230 -0.0220
0.0214 0.0205 0.0168 0.0141 0.0216 0.0212 0.0195 0.0183 0.0216 0.0213 0.0203
0.0766 0.0763 0.0753 0.0745 0.0767 0.0765 0.0761 0.0757 0.0767 0.0766 0.0763
0.1416 0.1415 0.1410 0.1405 0.1417 0.1416 0.1414 0.1412 0.1417 0.1416 0.1415
0.2167 0.2166 0.2162 0.2159 0.2167 0.2166 0.2165 0.2164 0.2167 0.2167 0.2166
0.3017 0.3016 0.3013 0.3011 0.3017 0.3017 0.3015 0.3015 0.3017 0.3017 0.3016
0.3967 0.3966 0.3964 0.3963 0.3967 0.3967 0.3966 0.3965 0.3967 0.3967 0.3966
Columns 12 through 20
-0.0212 -0.0233 -0.0231 -0.0224 -0.0219 -0.0233 -0.0232 -0.0228 -0.0225
0.0195 0.0216 0.0215 0.0207 0.0202 0.0217 0.0216 0.0212 0.0209
0.0761 0.0767 0.0766 0.0764 0.0763 0.0767 0.0767 0.0765 0.0765
0.1414 0.1417 0.1417 0.1415 0.1415 0.1417 0.1417 0.1416 0.1416
0.2165 0.2167 0.2167 0.2166 0.2165 0.2167 0.2167 0.2166 0.2166
0.3015 0.3017 0.3017 0.3016 0.3016 0.3017 0.3017 0.3017 0.3016
0.3966 0.3967 0.3967 0.3966 0.3966 0.3967 0.3967 0.3967 0.3966
0 个评论
采纳的回答
Voss
2022-2-19
Something like this?
X1 = [0.4000 0.5000 0.6000 0.7000 0.8000 0.9000 1.0000];
% pstar = cell2mat(pStar);
pstar = [ ...
-0.0230 -0.0222 -0.0188 -0.0162 -0.0232 -0.0228 -0.0213 -0.0202 -0.0232 -0.0230 -0.0220 -0.0212 -0.0233 -0.0231 -0.0224 -0.0219 -0.0233 -0.0232 -0.0228 -0.0225
0.0214 0.0205 0.0168 0.0141 0.0216 0.0212 0.0195 0.0183 0.0216 0.0213 0.0203 0.0195 0.0216 0.0215 0.0207 0.0202 0.0217 0.0216 0.0212 0.0209
0.0766 0.0763 0.0753 0.0745 0.0767 0.0765 0.0761 0.0757 0.0767 0.0766 0.0763 0.0761 0.0767 0.0766 0.0764 0.0763 0.0767 0.0767 0.0765 0.0765
0.1416 0.1415 0.1410 0.1405 0.1417 0.1416 0.1414 0.1412 0.1417 0.1416 0.1415 0.1414 0.1417 0.1417 0.1415 0.1415 0.1417 0.1417 0.1416 0.1416
0.2167 0.2166 0.2162 0.2159 0.2167 0.2166 0.2165 0.2164 0.2167 0.2167 0.2166 0.2165 0.2167 0.2167 0.2166 0.2165 0.2167 0.2167 0.2166 0.2166
0.3017 0.3016 0.3013 0.3011 0.3017 0.3017 0.3015 0.3015 0.3017 0.3017 0.3016 0.3015 0.3017 0.3017 0.3016 0.3016 0.3017 0.3017 0.3017 0.3016
0.3967 0.3966 0.3964 0.3963 0.3967 0.3967 0.3966 0.3965 0.3967 0.3967 0.3966 0.3966 0.3967 0.3967 0.3966 0.3966 0.3967 0.3967 0.3967 0.3966
];
% N2 = 5;
N2 = 4;
% for i5 = 0:N2:((N2*N2)-1)
for i5 = 0:N2:(N2*N2)
pstar1 = pstar(:,i5+1);
pstar2 = pstar(:,i5+2);
pstar3 = pstar(:,i5+3);
pstar4 = pstar(:,i5+4);
% pStar plot
% figure(3)
figure(i5+1)
plot(pstar1,X1,'+')
hold on
plot(pstar2,X1,'+')
plot(pstar3,X1,'+')
plot(pstar4,X1,'+')
hold off
title('Radial Distribution of Dimensionless Pressure')
xlabel('p*')
ylabel('x')
legend('{C}_{{w}_{1}}','{C}_{{w}_{2}}','{C}_{{w}_{3}}','{C}_{{w}_{4}}')
grid
end
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Interactive Control and Callbacks 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!