Plotting a 3D surface model with colours from excel

2 Ansichten (letzte 30 Tage)
Najim Popalzai
Najim Popalzai am 30 Nov. 2020
Beantwortet: Star Strider am 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 :)

Akzeptierte Antwort

Star Strider
Star Strider am 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.

Weitere Antworten (0)

Kategorien

Mehr zu Line Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by