MATLAB Answers

Surface Plot using excel file as a source

9 views (last 30 days)
Hello,
I am a new user to Matlab and I am trying to create a surface plot for data analysis, so it would be great if you can assist a fellow newbie.
Attached you will find a sample xls file .
When I am running the below script I am getting an error with the message "Data dimensions must agree."
Did I miss something? Thanks in advance and any help will be much appreciated.
filename = PlotData.xlsx';
num = xlsread(filename) ;
x = num(2:end,1) ;
y = num(1,2:end) ;
Z = num(2:end,2:end) ;
surf(x,y,Z)
  1 Comment
Andreas Kerasiotis
Andreas Kerasiotis on 20 May 2021
Thanks for your swift reply Mathieu, it worked like a charm.
Cheers.

Sign in to comment.

Accepted Answer

Mathieu NOE
Mathieu NOE on 19 May 2021
hello Andreas
simply , you inverted x and y vectors
this is correct :
filename = 'PlotData.xlsx';
num = xlsread(filename) ;
x = num(1,2:end) ;
y = num(2:end,1) ;
Z = num(2:end,2:end) ;
surf(x,y,Z)

More Answers (1)

KSSV
KSSV on 19 May 2021
x = A(1,2:end) ;
y = A(2:end,1) ;
Z = A(2:end,2:end) ;
surf(x,y,Z) ;
  2 Comments
Andreas Kerasiotis
Andreas Kerasiotis on 20 May 2021
Thanks for your swift reply KSSV, both your answer and Mathieu's worked.
Cheers.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!