I have been thrown in the deep end in one of my Signals classes. I am trying to learn Octave so that I can do the Matlab assignments required by the professor at home (I have not had any education in Matlab yet).
I have been reading as much as I can but I cannot seem to figure out why this function only seems to return 0. I think I am missing something fundamental but I don't know what.
t = [-1:0.1:5];
% (a): The Unit-step Function u(t)
function u = u (t)
if(t >= 0)
u = 1;
else
u = 0;
end
end
plot(t, u(t));
uin your function is a scalar not a vector. Try initializingu = zeros(size(t)), andu(t>=0) = 1. That should do it.