From: "Steven Lord" <>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Delayed Unit Step (Heaviside) Function on Matlab
Date: Mon, 25 May 2009 12:12:36 -0400
Organization: The MathWorks, Inc.
Lines: 43
Message-ID: <gveg17$p$>
References: <gvdq74$6mf$>
Reply-To: "Steven Lord" <>
X-Trace: 1243267943 25 (25 May 2009 16:12:23 GMT)
NNTP-Posting-Date: Mon, 25 May 2009 16:12:23 +0000 (UTC)
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.5512
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579
Xref: comp.soft-sys.matlab:542413

"Kola Ogidi" <> wrote in message 
> 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