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

4 Ansichten (letzte 30 Tage)
奥 刘
奥 刘 am 2 Nov. 2024
Kommentiert: 奥 刘 am 3 Nov. 2024
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?

Antworten (1)

Paul
Paul am 2 Nov. 2024
Bearbeitet: Paul am 2 Nov. 2024
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 Kommentare
Walter Roberson
Walter Roberson am 3 Nov. 2024
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))

Melden Sie sich an, um zu kommentieren.

Produkte


Version

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by