Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

New to MATLAB?

X Y Z Surface Plot Problem

Asked by Bora Tek

Bora Tek (view profile)

on 20 Apr 2012

Hello Friends,

I need your assistance about plotting x y z axis surface graphic

I have tunnel data on excel; Tunnel lenght, Temperature, Time

I want to show these datas on matlab

here is my datas

http://speedy.sh/sTARC/Matlab-icin.xlsx

Thank you so much

0 Comments

Bora Tek

Bora Tek (view profile)

Products

No products are associated with this question.

3 Answers

Answer by Matt Tearle

Matt Tearle (view profile)

on 20 Apr 2012
Accepted answer
data = xlsread('filename.xlsx');  % read in everything (numeric)
t = data(1,2:end);                % first row (except first element)
l = data(2:end,1);                % first column (except first element)
temp = data(2:end,2:end);         % actual data in the table
surf(t,l,temp)                    % make surface plot

2 Comments

Bora Tek

Bora Tek (view profile)

on 20 Apr 2012

Thank you so much Matt Tearle :)

I'm a rookie on matlab by the way :)

Matt Tearle

Matt Tearle (view profile)

on 20 Apr 2012

Welcome. No problem, we all start somewhere :)
http://www.mathworks.com/matlabcentral/answers/8026-best-way-s-to-master-matlab

Matt Tearle

Matt Tearle (view profile)

Answer by Bora Tek

Bora Tek (view profile)

on 20 Apr 2012

Thank you so much for your help Matt, This link will help me im sure :) I have one more question, can i change x axis position with y axis? if i can do that, do i have to change my excel data? i want to show my datas like this.

Here is the link : http://speedy.sh/A9vqW/heat-transfer-conduction-radiation-3dgraph-499px.png

Thank you

1 Comment

Matt Tearle

Matt Tearle (view profile)

on 23 Apr 2012

You mean exchange the x and y axes? Yes, just transpose your data matrix:

temp = data(2:end,2:end)';
surf(l,t,temp)

Bora Tek

Bora Tek (view profile)

Answer by Bora Tek

Bora Tek (view profile)

on 29 Apr 2012

Hi Matt,

I changed the code as you said;

data = xlsread('sıcaklık100mw.xlsx'); 
t = data(1,2:end);                
l = data(2:end,1);                
temp = data(2:end,2:end);        
surf(l,t,temp)

But i got this error message:

Error using surf (line 75)
Data dimensions must agree.

1 Comment

Matt Tearle

Matt Tearle (view profile)

on 30 Apr 2012

Note the transpose operator (') at the end of the command temp = data(2:end...

temp is a matrix with m rows and n columns. When making a surface plot, the m rows are taken to be the values at m y locations; the n columns are taken to be the values at n x locations. So when you do surf(x,y,temp), the x vector should have n elements, and y should have m elements. To switch x and y, you need to flip (transpose) the matrix *and* the x and y vectors in the surf command.

Bora Tek

Bora Tek (view profile)

Contact us