How to Create a Surface Plot from Table Data Imported from Excel

조회 수: 24 (최근 30일)
I am trying to create a surface plot for the excel table shown in the image below using the "surf" function. TetherK and TetherC are my inputs. Power is my output (the white cells). I can't seem to get the surf fucntion to work. I imported the data and have a table in MATLAB for TetherK, TetherC, and my Output (shown below). What do I need to do so that I can make a surface plot from tables in MATLAB?

채택된 답변

Scott MacKenzie
Scott MacKenzie 2022년 3월 3일
편집: Scott MacKenzie 2022년 3월 3일
Given some test data (attached) similar to yours...
... a surface plot can be created thus...
M = readmatrix('testdata.xlsx');
[X,Y] = meshgrid(M(1,2:end),M(2:end,1));
Z = M(2:end,2:end);
surf(X,Y,Z);
The test data are random values. Hopefully, your plot will look more interesting.
  댓글 수: 1
Michaela Byrne
Michaela Byrne 2022년 3월 4일
That worked, thanks! I'm including pictures of what I did in MATLAB to get it to work in case anyone else has a similar question to what I had and wants to see what I did.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Walter Roberson
Walter Roberson 2022년 3월 3일
x = PlotTestS1.TetherK;
y = PlotTestS2.TetherCn
z = table2array(PlotTestS3) ;
surf(x, y, z, 'edgecolor', 'none')

카테고리

Help CenterFile Exchange에서 Data Import from MATLAB에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by