Surface plot(Z must be a matrix, not a scalar or vector)
1 view (last 30 days)
Show older comments
Hello
I was trying to plot using the following surface graph but i get this error. Can someone help me please? Thank You
[b1,a1] =meshgrid(0.1:0.01:0.05,0.01:0.001:0.03);
b1 =0.22;
b2 =0.48;
a1 =0.006;
e1 =0.2;
e2 =0.2;
bh =0.000097;
bv =0.27;
r =0.0035;
d =0.3;
x =0.86;
u =0.00045;
v =0.10;
uc =0.55;
um =0.00034;
ue =0.7;
Nh =100;
Nv =100;
c=0.5;
m=20;
r=0.01;
Ro = (b1.*b2.*a1.*r.*bh.^2*bv.*Nh^2*Nv)./(u.^2.+v.*(d.^+u.^+ue)*(u.^+uc.^+r.^x)*(u.^+um.^+r));
surf(b1,a1,Ro)
hold on
z2 =0*b1+ 1
surf(b1,a1,z2,'MarkerFaceColor','red')
xlabel('\beta_1')
ylabel('\mu')
zlabel('R_0')
colorbar;
Error using surf (line 74)
Z must be a matrix, not a scalar or vector.
Error in SR1 (line 23)
surf(b1,a1,Ro)
0 Comments
Answers (1)
Takumi
on 24 Jun 2020
First of all, the argument of meshgrid is wrong.
0.1:0.01:0.05←must be greater than 0.1.
Second, variavle b1 and a1 has been overwritten.
Do you want to do something like that?
[b1,a1] =meshgrid(0.1:0.01:0.5,0.01:0.001:0.03);
% b1 =0.22;
b2 =0.48;
% a1 =0.006;
e1 =0.2;
e2 =0.2;
bh =0.000097;
bv =0.27;
r =0.0035;
d =0.3;
x =0.86;
u =0.00045;
v =0.10;
uc =0.55;
um =0.00034;
ue =0.7;
Nh =100;
Nv =100;
c=0.5;
m=20;
r=0.01;
Ro = (b1.*b2.*a1.*r.*bh.^2*bv.*Nh^2*Nv)./(u.^2.+v.*(d.^+u.^+ue)*(u.^+uc.^+r.^x)*(u.^+um.^+r));
surf(b1,a1,Ro)
hold on
z2 =0*b1+ 1
surf(b1,a1,z2,'MarkerFaceColor','red')
xlabel('\beta_1')
ylabel('\mu')
zlabel('R_0')
colorbar;
See Also
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!