How do I set the value of the heaviside function at the origin (or shifted origin) to be 1, not 0.5?
Show older comments
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
Oliver
on 15 Jan 2016
Edited: Geoff Hayes
on 15 Jan 2016
jgg
on 15 Jan 2016
I'd suggest answering your own question with this, so people know how to solve the problem.
Jovana Nojic
on 24 Mar 2017
You can use: round(heaviside(t-t'))
Accepted Answer
More Answers (2)
Stephen23
on 16 Jan 2016
This is equivalent to
myHeav = @(X)double(X>=0);
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
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!