Z must be a matrix, not a scalar or vector.
3 views (last 30 days)
Show older comments
I could't find the Problem. Need a help!!!
%variable declare
syms x;
syms t;
%putting the value
a=1;
b=-2;
c=-1;
alpha=1;
p=0;
%mesh plot
x = -3:.1:3;
y = -3:.1:3;
[X,Y] = meshgrid(x,t);
%vartheta equation
vartheta = ((a/alpha)*X.^alpha)+((b/alpha)*p^alpha)+c*t;
%delta equation
delta=-(2*c)/(b*a^2);
%main function
Z=-(2*(c^2)*((tanh(sqrt(-delta).*vartheta)).^2))/(b*delta*a^3);
mesh(X,Y,Z)
grid on
hold on
Result:
Error using mesh (line 71)
Z must be a matrix, not a scalar or vector.
Error in M3_1_29_3 (line 30)
mesh(X,Y,Z)
2 Comments
Jeffrey Clark
on 12 Jun 2022
Asuming you meant to use y or Y where t is used, vartheta should be computed as a matrix since X is used, and therefore Z would be a matrix. Since the error indicates that Z is not a matrix the code you shared must have other copy and paste issues. Please retest after removing the syms lines which may be causing some of the issue. Then upload that code if it still gives the error or something else.
Answers (1)
Walter Roberson
on 12 Jun 2022
%putting the value
a=1;
b=-2;
c=-1;
alpha=1;
p=0;
%mesh plot
x = -3:.1:3;
y = -3:.1:3;
[X,Y] = meshgrid(x,y);
%vartheta equation
vartheta = ((a/alpha)*X.^alpha)+((b/alpha)*p^alpha)+c*Y;
%delta equation
delta=-(2*c)/(b*a^2);
%main function
Z=-(2*(c^2)*((tanh(sqrt(-delta).*vartheta)).^2))/(b*delta*a^3);
mesh(X,Y,Z)
grid on
hold on
0 Comments
See Also
Categories
Find more on Number Theory 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!