Plotting a 3D surface model with colours from excel

2 vues (au cours des 30 derniers jours)
Najim Popalzai
Najim Popalzai le 30 Nov 2020
Hey
I need help for plotting a 3D surface model with colours based on my z axis. I have imported my data from excel into Matlab, however I am quite new to this software, so I am bit confused which commandoes should be used. The excel file is shared :)

Réponse acceptée

Star Strider
Star Strider le 30 Nov 2020
I am not certain what result you want.
One option:
T1 = readtable('dagslysdata.xlsx', 'HeaderLines',3);
Xv = linspace(min(T1.X), max(T1.X), 50);
Yv = linspace(min(T1.Y), max(T1.Y), 50);
[Xm,Ym] = ndgrid(Xv, Yv);
Zm = griddata(T1.X,T1.Y,T1.Z, Xm,Ym, 'natural');
figure
surf(Xm, Ym, Zm)
view(-30,30)
Another option:
Zm = griddata(T1.X,T1.Y,T1.Z, Xm,Ym, 'nearest');
figure
surf(Xm, Ym, Zm)
view(-30,30)
See the documentation on griddata for a full description of what it does, and linspace to understand how to create the ‘Xv’ and ‘Yv’ vectors (that then use ndgrid to create the ‘Xm’ and ‘Ym’ matrices) to get the resolution you want.

Plus de réponses (0)

Catégories

En savoir plus sur Line 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!

Translated by