Error Using Surface Plot

9 views (last 30 days)
Franklyn Dunbar
Franklyn Dunbar on 2 May 2017
Answered: Walter Roberson on 2 May 2017
Trying to make a three dimensional plot, with the third array being a function of the first two (long,lat,altitude for example).
To try get the syntax right, I am using a practice script.
Why would using the surf function following meshgrid on three variables not work?
q = [1:.1:15];
w = [1:.1:15];
zz = [1:.1:15];
[Q, W, ZZ] = meshgrid(q,w,zz);
figure(2)
surf(Q,W,ZZ)
colorbar

Answers (1)

Walter Roberson
Walter Roberson on 2 May 2017
Your Q, W, and ZZ variables are going to be 3D because you are using meshgrid() on 3 inputs.
The three inputs to surf() need to be 2D.
surf() cannot be used to create volume plots.

Community Treasure Hunt

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

Start Hunting!