3D surface plot from imported 2D excel array

조회 수: 11 (최근 30일)
joe pearson
joe pearson 2018년 3월 2일
편집: joe pearson 2018년 3월 3일
New to Matlab. Im sure this is answered somewhere already, but I can't manage to find it; I have a 2D array of experimental data tabulated in excel. 1st row and column are varied parameters, and I measure the corresponding amplitudes in the matrix. Importing the table to Matlab is simple. I would then like to plot a 3D surface of the 1st row (x) vs. 1st column (y), for the amplitudes in the matrix. This is very straightforward in excel, but the plots look terrible. Thanks in advance for the help.

채택된 답변

Star Strider
Star Strider 2018년 3월 2일
Try this:
[D,S,R] = xlsread('ExampleArray.xls');
figure(1)
ribbon(D(:,1), D(:,2:end))
grid on
[X,Y] = meshgrid((1:size(D,2)-1), D(:,1));
Z = D(:,2:end);
figure(2)
surf(X, Y, Z)
grid on
  댓글 수: 8
joe pearson
joe pearson 2018년 3월 3일
편집: joe pearson 2018년 3월 3일
That's almost what I wanted. I finally figured out how it works. Thanks again for all the help!! This is the code I am using, in case the next person to come along finds it useful;
[D,S,R] = xlsread('ExampleArray.xls');
Z = D(2:end,2:end);
M = max(max(Z));
figure(1)
X = D(1,2:end);
Y = D(2:end,1);
x1 = min(X);
x2 = max(X);
y1 = min(Y);
y2 = max(Y);
surf(X,Y,Z)
axis manual
xlim([x1 x2])
ylim([y1 y2])
colormap parula
shading interp
colorbar
caxis([0 M])
%view(2)
uncommenting the view(2) makes a nice psuedo 3D view
Star Strider
Star Strider 2018년 3월 3일
As always, my pleasure!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by