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

How to graphing a 3D surface when the X,Y,Z are known

Asked by Steve on 30 Nov 2012

I have an experiment where I have time (t) and temperature (T) as the variables and yield (Y) as the result. I have 3 times and 3 temperatures (t=[5,10,15] T=[30,40,50]) These are combined in 9 combinations so in (t,T) they would be (5,30), (10,30), (15,30), (10,30) etc... each of those combinations has produced a yield (Y), say (6,7,4,2,..etc). So I have all the values for (t,T,Y). Id like to plot these data points and get a 3D surface.

Should I plug all that into one matrix such as M=[5,30,6;10,30,7;15,30,4;...etc] so that each column represents an axis

Or should they all be separate like t=[5,10,15,10,15,5,15,5,10] T=[30,40,50,30,40,50,30,40,50] Y=[6,7,4,2,3,8,9,1,3] so that they are all in respect to each other

Or neither? What is the best way to go about this? Thank you

0 Comments

Steve

Products

No products are associated with this question.

2 Answers

Answer by owr on 30 Nov 2012

I typically use 3 2-dimensional matrices - one for each coordinate (t,T,Y) - each position corresponds to a combination of a t and T value, and of course the corresponding Y value.

Check out the documentation for "surf" for some examples The function "meshgrid" is also helpful for generating the matrices for t and T from the original vectors you specify.

0 Comments

owr
Answer by Azzi Abdelmalek on 30 Nov 2012
Edited by Azzi Abdelmalek on 30 Nov 2012
 t=[5,10,15]
 T=[30,40,50]
 [tt,TT]=meshgrid(t,T);
 y=sin(tt).*cos(2*TT);
 mesh(tt,TT,y)

0 Comments

Azzi Abdelmalek

Contact us