I am trying to create a 3D plot in Matlab.
I have a very long problem starting with the data set of Y and Z. With much manipulation it boils down to a simple y/z problem
y=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
z=[5, 10, 15, 20, 25, 30, 35, 40, 45, 50];
x=(y_new)/(z_new)
There is about 100 lines of equations manipulating y and z, to become two new variables y_new and z_new. I would like to create a 3d plot of x,y,z. I would want an x value for (1,5) and (1,10), (2,5), (2,10) etc.
The way I have the problem setup is only using y=1 and z=5. I have been trying to use for-loops or while-loops for the past few hours but I am getting stuck.
If someone can help me I would appreciate the time and effort!
You don’t need to use a
forloop. Instead, use the builtin functionmeshgrid()which is designed to solve exactly this problem.Here’s a tutorial from ‘abbe’ at MIT which details how to create a 3D plot of a function
f(x,y)usingmeshgrid().To quote the blurb: