Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

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

No tags are associated with this thread.

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.

Contact us