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 CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by