Error using mesh Z must be a matrix, not a scalar or vector. Error in untitled6 (line 5) mesh(W,Y,Z)

1 view (last 30 days)
Hi, I am trying to commute this 3D plot, however I am receiving an error.
w = 200:50:450;
y=180;
[W,Y] = meshgrid(w,y);
Z= 64.0189+1.4629*W-2.626*Y-0.0012*W.^2+0.0098*W.*Y+0.0082*Y.^2
mesh(W,Y,Z)
Error using mesh
Z must be a matrix, not a scalar or vector.
Error in untitled6 (line 5)
mesh(W,Y,Z)

Accepted Answer

KSSV
KSSV on 26 Jul 2022
As you have given single value of Z, it would be a line.
w = 200:50:450;
y=repmat(180,1,length(w));
[W,Y] = meshgrid(w,y);
Z= 64.0189+1.4629*W-2.626*Y-0.0012*W.^2+0.0098*W.*Y+0.0082*Y.^2
Z = 6×6
1.0e+03 * 0.4544 0.5887 0.7171 0.8394 0.9558 1.0661 0.4544 0.5887 0.7171 0.8394 0.9558 1.0661 0.4544 0.5887 0.7171 0.8394 0.9558 1.0661 0.4544 0.5887 0.7171 0.8394 0.9558 1.0661 0.4544 0.5887 0.7171 0.8394 0.9558 1.0661 0.4544 0.5887 0.7171 0.8394 0.9558 1.0661
mesh(W,Y,Z)
  6 Comments

Sign in to comment.

More Answers (1)

Chunru
Chunru on 26 Jul 2022
w = 200:50:450;
y=120:30:240;
[W,Y] = meshgrid(w,y);
Z= 64.0189+1.4629*W-2.626*Y-0.0012*W.^2+0.0098*W.*Y+0.0082*Y.^2;
whos
Name Size Bytes Class Attributes W 5x6 240 double Y 5x6 240 double Z 5x6 240 double cmdout 1x33 66 char w 1x6 48 double y 1x5 40 double
mesh(W,Y,Z)

Categories

Find more on Vector Fields in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!