matlab question response question
2 次查看（过去 30 天）
I have a control system with a PID controller, and im trying to simulate a system response, i need to plot the values first in a graph and then add the transfer function?
this is what i have found and im doing:
dt = 0.1; t = 0:dt:50; u = zeros(1,numel(t)); u(t<=20) = 45; u(t> 20 & t<=40) = -45; u(t> 40) = 0;
obviously with the lsim command
Is there a better way ?
Thanks in advance
Mischa Kim 2014-3-14
编辑：Mischa Kim 2014-3-14
John, you just need to build the signal (no need for plotting), e.g.,
dt = 0.1; % adjust as necessary
t = 0:dt:50;
u = zeros(1,numel(t));
u(t<=20) = 45; % you probably want to use rad instead of deg
u(t> 20 & t<=40) = -45;
u(t> 40) = 0;
and feed it as an input to the system.