How can I solve the second order differential equation using scilab ode() function.
(For example: y'' + 3y' +2y = f(x), y(0)=0, y'(0)=0)
And then plot the result of function y(x).
I want to use this to model the RLC-circuit signal with step-function input
Here is the code I tried
function y=u(t)
y=(sign(t)+1)/2
endfunction
L=0.001
R=10
C=0.000001
function zdot=f(t,y)
zdot(1)= y(2);
zdot(2)=(u(t)-y(1)-L*y(2)/R)/(L*C);
endfunction
y0=[0,0];
t0=0;
t=0:0.00001:0.001;
out=ode(y0,t0,t,f);
clf();
plot(out);
Thank you a lot
解决方案
You were nearly there, you only had problems with the shape of the vectors and how that affects t