필터 지우기
필터 지우기

Z must be a matrix, not a scalar or vector.

조회 수: 3 (최근 30일)
shahariar Ryehan
shahariar Ryehan 2022년 6월 12일
답변: Walter Roberson 2022년 6월 12일
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
Torsten
Torsten 2022년 6월 12일
편집: Torsten 2022년 6월 12일
Why do you define
y = -3:.1:3
and don't use "y" anywhere in your code ?
And in order to plot, t must be given a value - i can't remain a symbolic variable.
Why do you use symbolic variables at all ?
Jeffrey Clark
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
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

카테고리

Help CenterFile Exchange에서 Number Theory에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by