Second argument must be a scalar or vector of unique symbolic variables.
조회 수: 4 (최근 30일)
이전 댓글 표시
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?
댓글 수: 0
답변 (1개)
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))
Note: symbolic rendering still not working after submitting @Tushal Desai
댓글 수: 5
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))
참고 항목
카테고리
Help Center 및 File Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!