Thread Subject: Delayed Unit Step (Heaviside) Function on Matlab

Subject: Delayed Unit Step (Heaviside) Function on Matlab

From: Kola Ogidi

Date: 25 May, 2009 10:00:04

Message: 1 of 3

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.

I had previously created the normal unit step function as follows:

heaviside=(t>=0);

This worked ok but I'm not sure if this might have to do with the problem I'm encountering. Could you please advise me on what I need to do to achieve my aim.

Thanks in advance.
Kola

Subject: Delayed Unit Step (Heaviside) Function on Matlab

From: Sadik

Date: 25 May, 2009 15:39:02

Message: 2 of 3

Hi Kola,

heavisidesixtyfour=(t>=64);

can never give such an error because you are not doing any multiplication. The problem might be somewhere else. I believe, transposing t should solve the problem. So you would say:

heavisidesixtyfour=(t'>=64);

"Kola Ogidi" <kko_ogidi@yahoo.co.uk> wrote in message <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.
>
> I had previously created the normal unit step function as follows:
>
> heaviside=(t>=0);
>
> This worked ok but I'm not sure if this might have to do with the problem I'm encountering. Could you please advise me on what I need to do to achieve my aim.
>
> Thanks in advance.
> Kola

Subject: Delayed Unit Step (Heaviside) Function on Matlab

From: Steven Lord

Date: 25 May, 2009 16:12:36

Message: 3 of 3


"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

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com