Path: news.mathworks.com!not-for-mail From: "Steven Lord" <slord@mathworks.com> 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$1@fred.mathworks.com> References: <gvdq74$6mf$1@fred.mathworks.com> Reply-To: "Steven Lord" <slord@mathworks.com> NNTP-Posting-Host: lords.dhcp.mathworks.com X-Trace: fred.mathworks.com 1243267943 25 144.212.105.187 (25 May 2009 16:12:23 GMT) X-Complaints-To: news@mathworks.com 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: news.mathworks.com comp.soft-sys.matlab:542413 "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