|
"Kola Ogidi" <kko_ogidi@yahoo.co.uk> wrote in message
news:gvdq74$6mf$1@fred.mathworks.com...
> Hi,
>
> I'm trying to create a variable which holds a delayed unit step function
> which starts at 64 (rather than the normal unit step function which starts
> at 0). I named this variable Heavisidesixtyfour and used the following
> statement to try to implement it:
>
> heavisidesixtyfour=(t>=64);
>
> I also set the value at 63 (taking into account a problem I encountered
> recently which was resolved by including 0 time in my count). However, I
> am getting the following error message whichever way I try to run it:
>
> ??? Error using ==> mtimes
> Inner matrix dimensions must agree.
Note that * won't work to compute t*heavisidesixtyfour -- that's matrix
multiplication, not elementwise multiplication (.*) which is what I think
you want.
In this case, though, if you wanted to compute the Heaviside function on
multiple vectors, I'd create a function (or an anonymous function) that
accepts t and returns the desired vector.
function y = heavisideN(t, N)
y = (t >= N);
% or
heavisideN = @(t, N) (t>= N);
Then use that function:
t = 0:100;
y = t .* heavisideN(t, 63); % Note the use of .* instead of *
--
Steve Lord
slord@mathworks.com
|