MATLAB, how to input step functions.

Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
2 replies · 6K views
btbam91
Messages
91
Reaction score
0
Hey guys, I am extremely inexperienced with MATLAB and I"m struggling putting this ode into matlab.

y' = -a*y+u(t-1)-u(t-3)

I know that for y=u(t-1), you type:

if t<1
y=0;
else
y=1;
end

and for y=u(t-3):
if t<3
y=0;
else
y=1;

But I'm confused as to how you'd combine all of the above into a correction function m file!

Thanks!
 
Physics news on Phys.org
I am trying to understand your question here. Is your question you'd like to have a .m file that mimics the step function? type "help heaviside" see if that helps
 
Doesn't elseif solve the problem you are having?

if condition1
then something
elseif condition2
then something else
...
...
...
else
something
end