Error using surf - Z must be a matrix, not a scalar or vector.

2 views (last 30 days)
Hello, I am using matlab for optimization problem. I have to find the calculated values for maximum volume, radius and height and plot 3D surface between them
radius = sqrt(given_amount/2*3*3.14);
height = ((given_amount)/2*3.14*radius) - radius;
maximum_volume = (length*width*radius)/2 - 3.14*radius*radius*radius;
surf(radius,height,maximum_volume);
It says that z must be a vector.

Accepted Answer

Cris LaPierre
Cris LaPierre on 8 Dec 2018
Wow, this is a popular homework question this week.
"It says that z must be a vector."
It likely doesn't say Z has to be a vector. It probably says "Z must be a matrix, not a scalar or vector."
I'll get you started by pointing you to this post.
And, of course, send you to the documentation for surf.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!