Question on modelling system dynamics

I need to define a step input that starts at t =6 seconds only. Thus, I cannot use the in built step command. Ultimately i wish to model the dynamic response of a system in response to this input
How do I create a user defined function that does this?
I wrote a function
function [ res ] = mystep( a, b ) %Calculates the response ta a unit step input %with delay of 6 seconds
s=heaviside(b-6);
res = a*s;
end
But when i attempted to use it as follows >> num = [0,1]; den = [0,1]; G= tf(num, den); t = 0:0.1:10; Sys_Resp = mystep(G,t); plot(t,Sys_Resp) Error using plot Conversion to double from tf is not possible.
I get the above error. What have i done wrong?

Answers (1)

N=1;D=[1 2];
G=tf(N,D)
t1=0:0.1:6;
t2=6+0.1:0.1:20;
t=[t1 t2]
u_step=ones(1,length(t))
u_step(1:length(t1))=0
plot(t,u_step)
lsim(G,u_step,t)

Categories

Asked:

Lo
on 29 Oct 2012

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!