# How to write the following equation using matlab

3 views (last 30 days)
Commented: Sam Chak on 24 Sep 2022
Hi I would like to know how i should write the following equation in matlab. The equation will be used to sketch a graph but the correct graph is not being sketched and i feel like it has something to do with the way I wrote the equation. Could anyone please help me out
Torsten on 22 Sep 2022
Edited: Torsten on 22 Sep 2022
L = 1;
C = 1;
R = 1;
t = 0:0.0000001:0.003;
h = 2 * sin( sqrt(4*L-C*R^2)*t/(L*sqrt(2*C)) ) / (sqrt(C)*sqrt(4*L-C*R^2)) .* exp(-R*t/(2*L));
plot(t,h)

Walter Roberson on 21 Sep 2022
syms U L C R t
h(t) = 2*sin(sqrt(U*L - C*R^2)/(L*sqrt(2*L))*t) / (sqrt(C)*sqrt(4*L-C*R^2)) * exp(-t*(R/2*L))
h(t) =
Unfortunately you have to look very closely to see that the exponent is negative; I will remind Mathworks again that the negative exponent needs to be more clear.
You would need specific numeric values for C L R U in order to be able to plot this.
Sam Chak on 24 Sep 2022
Jadida, I'd suggest you show us the ordinary differential equation of RLC circuit.
We can probably use dsolve to verify if the analytical solution is the same as the equation provided by you.