How to plot the surface of multiple data sets ?
조회 수: 12 (최근 30일)
이전 댓글 표시
I have three different data sets each being constant in the z/l axis and want to plot the surface of them. I got the 3d plot working using plot3() :
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/716974/image.png)
All three lines have the same amount of data points so it should not be that hard to connect each point of each line with a straight line.
Here's the code for the figure:
figure(35);
set(gcf,'position',[x0,y0,width,height])
plot3(porous_upper(pathnumber_10,1).values(:,xc_x)*scale_x,porous_upper(pathnumber_10,1).values(:,xc_x+2)*scale_z,porous_upper(pathnumber_10,1).values(:,yc_x),"DisplayName","Porous Upper 1 p -10");
hold on;
plot3(porous_upper(pathnumber_10,2).values(:,xc_x)*scale_x,porous_upper(pathnumber_10,2).values(:,xc_x+2)*scale_z,porous_upper(pathnumber_10,2).values(:,yc_x),"DisplayName","Porous Upper 2 p -10");
hold on;
plot3(porous_upper(pathnumber_10,3).values(:,xc_x)*scale_x,porous_upper(pathnumber_10,3).values(:,xc_x+2)*scale_z,porous_upper(pathnumber_10,3).values(:,yc_x),"DisplayName","Porous Upper 3 p -10");
title(["Pressure p above porous layer";"Sidecoefficent Test -10"],'interpreter','latex',"FontSize",20)
set(gca, 'YDir','reverse')
xlabel('X/L', 'Interpreter','latex',"FontSize",16);
ylabel('Z/L', 'Interpreter','latex',"FontSize",20);
zlabel('$p$', 'Interpreter','latex',"FontSize",20);
legend("show","Location","Best","AutoUpdate", "off");
댓글 수: 0
채택된 답변
Star Strider
2021년 8월 20일
It would help to have the actual data.
N = 20;
X = (0:N-1);
Y = [1:3].'+zeros(size(X));
porous_upper = rand(20,3)+[0:2];
figure
plot3(X, Y(1,:), porous_upper(:,1))
hold on
plot3(X, Y(2,:), porous_upper(:,2))
plot3(X, Y(3,:), porous_upper(:,3))
hold off
grid on
figure
surf(porous_upper.')
Make appropriate changes to work with your data.
.
댓글 수: 6
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!