Plotting a 3D surface model with colours from excel

4 views (last 30 days)
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 :)

Accepted Answer

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

More Answers (0)

Categories

Find more on Line Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!