write a matlab code using the “lsim” command and find the response. use same parameter values of part (b) but consider the initial conditions to be all zero, and input is fa=sin(3t)-2cos(t) in matlab

To write a MATLAB code using the "lsim" command and find the response for the given input and initial conditions, follow the steps below:

  1. Define the system transfer function and the input signal.
  2. Set the initial conditions to zero.
  3. Define the time axis.
  4. Use the "lsim" command to find the response.

Here is the MATLAB code:

main.m
% Define the system transfer function
num = [4 6 5];
den = [1 4 3];

% Define the input signal
t = 0:0.01:10;
fa = sin(3*t) - 2*cos(t);

% Set the initial conditions to zero
x0 = zeros(size(den) - 1);

% Find the response using lsim command
[y, t, x] = lsim(num, den, fa, t, x0);

% Plot the response
plot(t, y);
xlabel('Time');
ylabel('Response');
title('System Response');
375 chars
20 lines

Make sure you have the Control Systems Toolbox installed in order to use the "lsim" command.

gistlibby LogSnag