How to write the following equation using matlab

7 views (last 30 days)
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
  3 Comments
Jadida
Jadida on 22 Sep 2022
This is how I wrote my equation:
h = ((2*sin(((4*L-C*R^2)^0.5)*t/(L*(2*C)^0.5)))/((C^0.5)*(4*L-C*R^2)^0.5)).*(exp((-1*R*t)/(2*L)));
and this is the array t:
t = 0:0.0000001:0.003;
Torsten
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)

Sign in to comment.

Answers (1)

Walter Roberson
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.
  7 Comments
Torsten
Torsten on 24 Sep 2022
Edited: Torsten on 24 Sep 2022
The same graph compared to which graph ?
As I said, sqrt(4*L-C*R^2) becomes complex-valued for your parameter value for L, C and R.
You will have to change them or alternatively plot real(h), imag(h) or abs(h).
Sam Chak
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.

Sign in to comment.

Categories

Find more on Line Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!