Simulate output with given input and transfer function

Ming Sun

Ming Sun / November 01, 2022

1 min read––– views

The following code calculates VOUT waveform for a given RLC network and VIN[1].

verify.m
clc;clear;close all;
% component parameter
R = 1e3;
L = 10e-3;
C = 50e-9;
% time 
t = linspace(0,2e-3,10000);
% Input
Vin = 3*cos(t.*t.*t*1e11);
% Transfer function
s = tf('s');
G = R/(R + s*L + 1/(s*C));
% Calculate Vout
Vout = lsim(G, Vin, t);
% Plot
plot(t*1e3, Vin, 'b', 'LineWidth',1.5);
hold on;
plot(t*1e3, Vout, 'r', 'LineWidth',1.5);
ylim([-4, 4]);
xlabel("time [ms]");
grid on;
legend(["Vin", "Vout"]);
Simulation result from Matlab
Fig. 1Simulation result from Matlab

References and materials

[1] MathWorks blog post


HomeWikis
SnippetsAbout
Google ScholarLinkedIn