- #1

- 37

- 0

## Main Question or Discussion Point

Hi Guys,

I am trying to create a basic unit step function in Matlab that needs to be in the range of"

-5 <= x <= 5

I need this to be done via a function and not piece together using different intervals and it needs to show the whole -5 to 5 interval. I am just beginning in Matlab and am stuck on where to start after creating the interval, which I made by using the following command:

%create the interval

x = -5 : 1 : 5

If anyone can give me guidance on how to start after this, it would be greatly appreciated. I tried using an if function with the following logic:

if x > 0, plot the graph of the unit step of magntiude 1

if x < 0, just plot 0's from the interval -5 to 0

This does not seem to work. Any help would be greatly appreciated!

I am trying to create a basic unit step function in Matlab that needs to be in the range of"

-5 <= x <= 5

I need this to be done via a function and not piece together using different intervals and it needs to show the whole -5 to 5 interval. I am just beginning in Matlab and am stuck on where to start after creating the interval, which I made by using the following command:

%create the interval

x = -5 : 1 : 5

If anyone can give me guidance on how to start after this, it would be greatly appreciated. I tried using an if function with the following logic:

if x > 0, plot the graph of the unit step of magntiude 1

if x < 0, just plot 0's from the interval -5 to 0

This does not seem to work. Any help would be greatly appreciated!