M file is for matlab Run the m-file below to find the time response of problem 1
ID: 2082100 • Letter: M
Question
M file is for matlab
Run the m-file below to find the time response of problem 1 (Homework 2), i.e., Y(s)/U(s) = s+1/s^2 +5s + 6 with step input. Print out the plot. Modify the m-file when the input is sin(pi*t) (i.e. sin(pi t)) and print out the plot. M-File % define symbolic variables s and t syms s t % define input function. ut = t^0; % input is step function sys = (s+1)/(s^2+5*s+6); % system transfer function. yt = sys_response(sys, ut); % input is step function % compute numerical values of output when time is from 0 to 5 sec, % with 0.01 sec time intervals time = 0:. 01: 5; y = subs(yt, time); %plot output y(t) plot time, y)Explanation / Answer
Thanks for choosing chegg!! here's the matlab code...
clear all;
close all;
clc
syms s t
ut=t^0;
numr=[1 1]
demr=[1 5 6];
sys=tf(numr,demr)
step(sys)% step response
% yt=step(sys);
yt=step(sys);
% yt=sys_response(sys,ut);
figure;
time=0:0.01:0.5;
y=subs(yt,time);
plot(time,y);
% the laplace transform of sin(at) is a^2/(s^2+a^2)
%this can be put into the transfer function and then generate the response
%s^4+5s^3+6s^2+pi^2s^2+5pi^2s+6pi^2
%impulse response of this function will give the required response for
%sin(pi*t) input
num2=[1 pi^2];
dem2=[1 5 6+pi^2 5*pi^2 6*pi^2];
syssine=tf(num2,dem2)
figure;
impulse(syssine);
Thank you!! Happy learning!! :)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.