Z must be a matrix, not a scalar or vector.
조회 수: 3 (최근 30일)
이전 댓글 표시
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
Jeffrey Clark
2022년 6월 12일
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.
답변 (1개)
Walter Roberson
2022년 6월 12일
%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
참고 항목
카테고리
Help Center 및 File Exchange에서 Number Theory에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!