How can i write this code and plot it on matlab?

I have a TF of H(s) and i dont know how to write code to plot it on matlab . We already solved it and i wanna use matlab to see if result are true. Can you help me please?
R= 10 k ohm.
L = 14.95 mH
C= 0.018013 pF
H(s) = R / ( R + Ls + (1 / Cs) ) = (R/L)s / ( s^2 + (R/L)s + 1/(LC) )

 Accepted Answer

I would be tempted to use the Control System Toolbox —
R= 10; % k ohm.
L = 14.95; % mH
C= 0.018013; % pF
s = tf('s');
H(1) = R / ( R + L*s + (1 / C*s) )
H = 10 ------------ 70.47 s + 10 Continuous-time transfer function.
H(2) = (R/L)*s / ( s^2 + (R/L)*s + 1/(L*C) )
H = From input 1 to output: 10 ------------ 70.47 s + 10 From input 2 to output: 0.6689 s ---------------------- s^2 + 0.6689 s + 3.713 Continuous-time transfer function.
figure
step(H)
I have no idea what is writtien on the whiteboard. Plot whatever it requires.
.

4 Comments

Thank you very much this is enough for me and very useful. I just tried myself and i wrote the code below. But i wanna ask when i write this code matlab give me error. What is the problem on it? How can i write it and take tf with this way?
num = [a 0]
den = [1 a b]
H = tf(num,den)
" Error using tf (line 303) The values of the "Numerator" and "Denominator" properties must be row vectors or cell arrays of row vectors, where each vector is nonempty and containing numeric data. Type "help tf.num" or "help tf.den" for more information."
u = symunit;
R= 10*u.kOhm ;
L = 0.1495*u.mH;
C= 0.018013*u.pF;
a= R/L
b= 1/(L*C)
num = [a 0]
den = [1 a b]
H = tf(num,den)
The Symbolic Math Toolbox symunit property (and others) do not work with Control System Toolbox objects. The only unit properties available are with respect to time and frequency. It is necesasry to make those conversion manually for them to have any effect —
R= 1E+4 ;
L = 0.1495E-3;
C= 0.018013E-12;
a= R/L
a = 6.6890e+07
b= 1/(L*C)
b = 3.7134e+17
num = [a 0]
num = 1×2
1.0e+07 * 6.6890 0
den = [1 a b]
den = 1×3
1.0e+17 * 0.0000 0.0000 3.7134
H = tf(num,den)
H = 6.689e07 s --------------------------- s^2 + 6.689e07 s + 3.713e17 Continuous-time transfer function.
figure
bode(H)
figure
step(H)
figure
impulse(H)
figure
pzplot(H)
format longE
polesH = pole(H)
polesH =
-3.344481605351172e+07 + 6.084589722465005e+08i -3.344481605351172e+07 - 6.084589722465005e+08i
zerosH = zero(H)
zerosH =
0
.
My pleasure!
I mistyped some of the unit conversions. The code is now correct.
If my Answer helped you solve your problem, please Accept it!
.

Sign in to comment.

More Answers (0)

Categories

Find more on MATLAB 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!