I have a complicated differential equation that cannot have explicit solution for m>=3. I am trying to plot the solution so that I can use the data.
%parameters
ed=0.001;
Ev=1000;
n=4000;
m=3;
ed=0.001;
syms y(t)
cond = y(0) == 0;
eq= diff(y,t) == (1/m)*(((Ev*(ed*t-y))/n)^m);

 Akzeptierte Antwort

Star Strider
Star Strider am 6 Aug. 2018
Bearbeitet: Star Strider am 6 Aug. 2018

0 Stimmen

Add this to the end of your posted code:
[VF,Subs] = odeToVectorField(eq);
DE = matlabFunction(VF, 'Vars',{t,Y});
[t,y] = ode45(DE, [0 10], 0);
figure(1)
plot(t, y)
grid
EDIT The complete code then becomes:
syms y(t) Y t
%parameters
ed=0.001;
Ev=1000;
n=4000;
m=3;
ed=0.001;
cond = y(0) == 0;
eq = diff(y,t) == (1/m)*(((Ev*(ed*t-y))/n)^m);
[VF,Subs] = odeToVectorField(eq);
DE = matlabFunction(VF, 'Vars',{t,Y});
[t,y] = ode45(DE, [0 10], 0);
figure(1)
plot(t, y)
grid

2 Kommentare

Thank you. It's working.
Star Strider
Star Strider am 7 Aug. 2018
As always, my pleasure.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Produkte

Version

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by