Plotting a 3D surface model with colours from excel

2 ビュー (過去 30 日間)
Najim Popalzai
Najim Popalzai 2020 年 11 月 30 日
回答済み: Star Strider 2020 年 11 月 30 日
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 :)

採用された回答

Star Strider
Star Strider 2020 年 11 月 30 日
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.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by