![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/432728/image.jpeg)
3D plot of 3 vectors
63 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Francesco Porretta
il 28 Nov 2020
Commentato: Ameer Hamza
il 28 Nov 2020
- error -
1 Commento
Ameer Hamza
il 28 Nov 2020
Original question asked by Francesco Porretta, restored from cache: http://webcache.googleusercontent.com/search?q=cache:https://www.mathworks.com/matlabcentral/answers/666483-3d-plot-of-3-vectors
Dear all, I have the three vectors reported in the file "data.mat" (x,y,z respectively).
I need to 3D plot them. However, something strange happen, since the z vector is 0 all around the borders, but plotting it I obtained that z is 0 only in 4 points (along y=0 axis), as shown in the figure below:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/432728/image.jpeg)
I wrote this code, to do the plot above:
x = data(:,1);
y = data(:,2);
[X,Y] = meshgrid(x,y);
z = data(:,3)
Z = meshgrid(z);
sup = surf(X,Y,Z)
thanks in andvance for your help
Risposta accettata
Ameer Hamza
il 28 Nov 2020
You first need to convert your data into a grid format using scattered interpolation
x = data(:,1);
y = data(:,2);
z = data(:,3);
mdl = scatteredInterpolant(x, y, z);
[xg, yg] = meshgrid(unique(x), unique(y));
zg = mdl(xg, yg);
sup = surf(xg,yg,zg)
2 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Discrete Data Plots in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!