Question:
Use this method to solve the following IVP:
A series RC circuit with R = 5 W and C = 0.02 F is connected with a battery of E = 100 V. At t = 0, the voltage across the capacitor is zero.
(a) Obtain the subsequent voltage across the capacitor.
(b)find the true error if the exact solution is: Vc = V(1 – e^(–t/RC))
Hint:
Use the formula
r(dq/dt)+(q/c)=v
———————————————
It is giving me msg operator '*' is not supported for operands of type 'function_handle'
also i wanna ypu give me advices on my work if i working right or wrong to improve as it`s my first time to use matlab
My Work:
R=5;C=0.02;E=100;Y0=0;Xinitial=0;Xfinal=1; h=0.01;X=Xinitial:h:Xfinal;Y = zeros(size(X));N=(Xfinal-Xinitial)/h;for i=1:N-1Ydot=@(t,q) (E-q/C)/R;Y(i+1) = Y(i) + h*(Ydot);endVreuler= Y0 / C;Exact=E * (1 - exp(-X/(R*C)));Error=(Exact-Vreuler)/Exact;polt(x.y); grid onh
Best Answer