Fractional-N
Full Member level 1
how to solve differential equation by matlab
i want to solve the above differential equation in matlab.
i wrote this m-file:
the above program return an error:
then i removed the 2 last line and type it in command window. the error is gone but the plot is a line. it must be a sinusoidal.
i want to solve the above differential equation in matlab.
i wrote this m-file:
Code:
function dv=diffv(t,vv)
vv=[0;1];
v=vv(1);
vdot=vv(2);
l=1e-5;
c=1e-6;
vdot=vdot;
vdoubledot=5/(l*c)-vdot/c*(3/10*(v-21/4)^2-2)-vdot/(l*c);
dv=[vdot;vdoubledot];
[T,V]=ode15s(@diffv,[0 0.1],[0 0]);
plot(T,V(:,1),'-')
the above program return an error:
??? Maximum recursion limit of 500 reached. Use set(0,'RecursionLimit',N)
to change the limit. Be aware that exceeding your available stack space can
crash MATLAB and/or your computer.
Error in ==> funfun\private\odearguments at 227
then i removed the 2 last line and type it in command window. the error is gone but the plot is a line. it must be a sinusoidal.
Code:
function dv=diffv(t,vv)
vv=[0;1];
v=vv(1);
vdot=vv(2);
l=1e-5;
c=1e-6;
vdot=vdot;
vdoubledot=5/(l*c)-vdot/c*(3/10*(v-21/4)^2-2)-vdot/(l*c);
dv=[vdot;vdoubledot];