MATLAB: Plotting 3 independent data and 1 response (output)

data of 3 independent variables and data of one dependent variableplotting 3 independent data and 1 responseresponse surface

Hello
I have data of 3 independent variables and one output. you can think of it as 3 columns of data and one response variable. I wonder if I can plot a surface that shows the variation in the respons or output variable as the other 3 data variables change.
Thank you
Aziz

Best Answer

What you are requesting would require a 4 dimensional plot. Let's call the output variable P and the inputs x,y,z. Several options exist:
1. Make surface plots of P on the vertical axis versus pairs of input variables, while holding the third variable constant: P vs x,y at fixed z; P vs y,z at fixed x; P vs z,x at fixedy.
2. Calculate a surface of constant P and make a 3D plot of that surface in x,y,z space. This sounds hard but Matlab has a great funciton, isosurface(), to make this easy.
The plots below illustrate option 1 (left) and option 2 (right), for the function
p(x,y,z)=(1-abs(x))*cos(y*pi/2)*cos(z*pi*3);
Code to make the figures is attached. The same color scale is used in both sets of plots. The left hand plots have p() on the vertical axis; the right hand plots show surface of constant p, in x,y,z space. For the plots on the right, I rotated each plot by hand to a perspective that I liked more than the default perspective, before doing the screen shot. When you hover the cursor over the plot area for a few seconds, some icons appear at the top right of the plot area. One icon is a little cube with a circular arrow around it. Click it. Then you can click and driag in the plot area to rotate it in 3D.