How can I generate a repetition of impulse response when I feed the system with repetition of pulses?
4 次查看(过去 30 天)
显示 更早的评论
MathWorks Support Team
2013-11-12
回答: MathWorks Support Team
2013-11-12
I have the transfer function for a system and I want to generate a repetition of pulses as the input to the system and output the impulse response of the input pulses. The impulse response should be a repetition of the system impulse response.
采纳的回答
MathWorks Support Team
2013-11-12
We can use the Control System Toolbox to do this.
The following code generates the system from the transfer function using 'tf' function
close all, clear all, clc
t=[0:.2e-3:1]; % Time vector
C=1e-2; L=20e-4; R=80e-3; % System parameters
a=1; b=[L*C R*C 1]; % Denominators and numerators
sys=tf([a],[b]) % Transfer function
impulse(sys) % Just a single pulse
Then we can generate the repetition of pulses and invoke the system impulse response using 'lsim' function.
% Generate input pulses
dt = 0.0002; %Sample rate
tend = 2.5; %Simulation period
t = 0:dt:tend;
period = 0.5; %Period of the input pulses
u = zeros(length(t),1);
for i=1:length(t)
if rem(t(i),0.5)==0
u(i)=1;
end
end
% Invoke the system response
% sysd = c2d(sys,dt); % Continuous to discrete system conversion.
[y yt] = lsim(sys,u,t);
y = y/dt; % Normalize with sample time.
% Plot the input and the output.
subplot(2,1,1);
plot(t,u);
title('Input');
subplot(2,1,2);
plot(yt,y);
title('Impulse Responce');
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Get Started with Control System Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!