Second argument must be a scalar or vector of unique symbolic variables.

조회 수: 4 (최근 30일)
奥 刘
奥 刘 2024년 11월 2일
댓글: 奥 刘 2024년 11월 3일
I was using dsolve to solve a differential equation. The code is:
clear all; close all; clc;
syms X;
syms gamma;
syms Y;
syms p(t);
ode = diff(p,t) == X * p ^ (3/2 - 1 / (2 * gamma)) - Y * diff(p,t);
ysol(t) = dsolve(ode);
but I got the error:
Error using symfun.validateArgNames (line 122)
Second argument must be a scalar or vector of unique symbolic variables.
Error in symfun (line 144)
y.vars = symfun.validateArgNames(inputs);
Error in symfun/privResolveArgs (line 291)
argout{k} = symfun(argout{k},fvars);
Error in sym/privBinaryOp (line 1072)
args = privResolveArgs(A, B);
Error in ^ (line 382)
B = privBinaryOp(A, p, 'symobj::mpower');
Error in differential_function (line 8)
ode = diff(p,t) == X * p ^ (3/2 - 1 / (2 * gamma)) - Y * diff(p,t);
So, could anyone tell me what is wrong?
And after I restrated MATLAB and reran the code, I got different errors, like:
Error using mupadengine/feval2sym_NaNsingularity
No differential equations found. Specify differential equations by using symbolic functions.
Error in dsolve>mupadDsolve (line 334)
T = feval2sym_NaNsingularity(symengine,'symobj::dsolve',sys,x,options);
Error in dsolve (line 203)
sol = mupadDsolve(args, options);
Error in differential_function (line 10)
ysol(t) = dsolve(ode);
Related documentation
Maybe somthing wrong with my PC?
And I use MATLAB online, I got
Also, actually the equation was solved at first and I did not change a thing, where the answer is
So, why suddenly it failed and why there is a zero in the second line of the solution?

답변 (1개)

Paul
Paul 2024년 11월 2일
편집: Paul 2024년 11월 2일
No error if running here w/2024b, nor did I get an error running on my local machine with 2024a
syms X;
syms gamma;
syms Y;
syms p(t);
ode = diff(p,t) == X * p ^ (3/2 - 1 / (2 * gamma)) - Y * diff(p,t)
ysol(t) = dsolve(ode)
p(t) = 0 is a trivial solution to the differenial equation, but I'm not sure why it's being returned. As far as I know, the trivial solution is typically not returned.
disp(char(ysol))
[((1/(2*gamma) - 1/2)*(C1 + (X*t)/(Y + 1)))^(1/(1/(2*gamma) - 1/2)); 0]
Note: symbolic rendering still not working after submitting @Tushal Desai
  댓글 수: 5
Walter Roberson
Walter Roberson 2024년 11월 3일
The problem is not with diff() -- if it were then it would have complained about diff() since diff() is earlier in the expression.
The problem it is complaining about is
Error in ^ (line 382)
refering to
ode = diff(p,t) == X * p ^ (3/2 - 1 / (2 * gamma)) - Y * diff(p,t);
the ^ is between the p and the (3/2 - 1 / (2 * gamma))
奥 刘
奥 刘 2024년 11월 3일
@Walter Roberson Yes! That's the problem. Really thanks Walter!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

제품


릴리스

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by