Unit step function - Explain this 10 line code?
3 views (last 30 days)
I have difficulty understanding what is happening with this code. It is meant to simulate the unit step function
(t-a)=1 for t>a and (t-a)=0 for t<a
The resulting output is vector of 0's and 1's when its inside another function. However, when I extract the function for simplicity to show here, it just calculates a bunch of 1's. In either case, i dont understand the 3rd last line...
function y = h(t)
t = linspace(0,36*pi,2^15)';
y = zeros(size(t));
for k = 1:length(t)
y(k) = 1;
y(k) = 0;
function y = U(t,i,N,Tc)
y = 0;
y = y + h(t-(((n-1)*N+i-1)/N)*Tc) - h(t-(((n-1)*N+i)/N)*Tc);