Filter löschen
Filter löschen

Explicit solution could not be found.. > In dsolve at 194

2 Ansichten (letzte 30 Tage)
here is my code :
>>sums u(t) v(t)
>>ode1= diff(u)==u^2/v - u
>>ode2= diff(v) == u^2-v
>>odes=[ode1;ode2]

Akzeptierte Antwort

Star Strider
Star Strider am 1 Jun. 2017
An analytic (symbolic) solution does not exist. You must us a numeric solver.
The Code
syms T t u(t) v(t) u0 v0 Y
Du = diff(u);
Dv = diff(v);
ode1 = Du == u^2/v - u;
ode2 = Dv == u^2-v;
[ode_vf, ode_subs] = odeToVectorField(ode1,ode2);
ode_fcn = matlabFunction(ode_vf, 'vars',{T,Y});
tspan = linspace(0, 10, 150);
icv = [0; 0]+sqrt(eps);
[t,y] = ode45(ode_fcn, tspan, icv);
figure(1)
plot(t, y)
grid
  23 Kommentare
siddharth tripathi
siddharth tripathi am 9 Jul. 2017
Hi star ! I hope you are doing good.
Can you please tell me how i can get graphs of u vs t and v vs t individually from this code ?
Thanks!
Star Strider
Star Strider am 9 Jul. 2017
My pleasure.
Here you go:
syms T t u(t) v(t) u0 v0 Y
Du = diff(u);
Dv = diff(v);
ode1 = Du == u^2/v - u;
ode2 = Dv == u^2-v;
[ode_vf, ode_subs] = odeToVectorField(ode1,ode2);
ode_fcn = matlabFunction(ode_vf, 'vars',{T,Y});
tspan = linspace(0, 10, 250);
icv = [0; 0]+sqrt(eps);
[t,y] = ode45(ode_fcn, tspan, icv);
figure(1)
plot(t, y)
grid
lgndc = sym2cell(ode_subs); % Get Substituted Variables
lgnds = regexp(sprintf('%s\n', lgndc{:}), '\n','split'); % Create Cell Array
legend(lgnds(1:end-1), 'Location','NW', 'Location','NE') % Display Legend
figure(2)
subplot(2,1,1)
plot(t, y(:,1))
title([lgnds{1} '(t)'])
xlabel('\bft\rm')
ylabel('\bfAmplitude\rm')
subplot(2,1,2)
plot(t, y(:,2))
title([lgnds{2} '(t)'])
xlabel('\bft\rm')
ylabel('\bfAmplitude\rm')

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Walter Roberson
Walter Roberson am 2 Jun. 2017
Making the assumption that you made a minor typing mistake in entering your question, and that you are asking about
syms u(t) v(t)
ode1= diff(u)==u^2/v - u;
ode2= diff(v) == u^2-v;
odes = [ode1;ode2];
dsolve(odes)
then MATLAB is not able to provide analytic solutions. However, two analytic solutions exist:
1)
u(t) = 0
v(t) = C1 * exp(-t)
where C1 is an arbitrary constant whose value depends upon the initial conditions
2)
u(t) = RootOf(-Intat(-LambertW(-C1*exp(a_)/a_)/(a_*(LambertW(-C1*exp(a_)/a_)+1)), a_ = Z_) + t + C2)
v(t) = u(t)^2/(diff(u(t), t)+u(t))}
that ugly formula for u(t) says that there is a particular function involving a ratio of LambertW formulas, and that for any given t, u(t) is the value such that the integral of the ratio, evaluate at that value, is 0.
This is ugly. But it does provide a path to an analytic solution, of sorts. But it is beyond the capacity of MATLAB.

Community Treasure Hunt

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

Start Hunting!

Translated by