How to plot the surface of multiple data sets ?
12 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Jean Volkmar
le 20 Août 2021
Commenté : Star Strider
le 20 Août 2021
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 commentaires
Réponse acceptée
Star Strider
le 20 Août 2021
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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Surface and Mesh Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!