How do I set the value of the heaviside function at the origin (or shifted origin) to be 1, not 0.5?

10 views (last 30 days)
I'm running Matlab R2014a, and I'd like to utilise the heaviside function to activate different parts of an equation at different points in time.
At a time t', a term becomes valid, so I'd like the full magnitude of that. By using heaviside as is, I get 0.5 times that term for the first array value, then the full magnitude there after. i.e. heaviside(t-t').*y, where y is a function to be acitvated at t=t'. I get 0.5*y(t'), when I would like 1*y(t').
After checking online, it seems the 'sympref' function is not on this version of matlab, so does anyone know the correct method?
  4 Comments

Sign in to comment.

Accepted Answer

Oliver
Oliver on 1 Mar 2016
This works fine, but there's probably a more elegant way to do it...
theta2 = heaviside(t-t')';
theta2(t') = theta2(t')*2;

More Answers (2)

Stephen23
Stephen23 on 16 Jan 2016
This is equivalent to
myHeav = @(X)double(X>=0);

Jos (10584)
Jos (10584) on 1 Mar 2016
theta2 = ceil(heaviside(t-t_origin))
which is the same as Stephens solution,
theta2 = double(t >= t_origin)
which is also much faster ...

Categories

Find more on MATLAB in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!