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:
Piecewise Plot

Subject: Piecewise Plot

From: Shaun Hurley

Date: 22 Sep, 2011 20:59:13

Message: 1 of 3

I am looking to plot my results as a piecewise function. I get an answer of something like:

y = [1 3 -5 6 3]

If I have an initial array of x = [0 1 2 3 4 5] does anyone know how I can plot x vs. y? I am looking for 5 discontinuous horizontal lines:
y = 1 for x[0,1]
y = 3 for x[1,2]
y = -5 for x[2,3]
y = 6 for x[3,4]
y = 3 for x[4,5]

Any ideas? Thank you!

Subject: Piecewise Plot

From: Kfupm engsub

Date: 22 Sep, 2011 21:52:11

Message: 2 of 3

"Shaun Hurley" wrote in message <j5g7j1$101$1@newscl01ah.mathworks.com>...
> I am looking to plot my results as a piecewise function. I get an answer of something like:
>
> y = [1 3 -5 6 3]
>
> If I have an initial array of x = [0 1 2 3 4 5] does anyone know how I can plot x vs. y? I am looking for 5 discontinuous horizontal lines:
> y = 1 for x[0,1]
> y = 3 for x[1,2]
> y = -5 for x[2,3]
> y = 6 for x[3,4]
> y = 3 for x[4,5]
>
> Any ideas? Thank you!


You can use unit step function

help heaviside

Subject: Piecewise Plot

From: TideMan

Date: 23 Sep, 2011 04:16:12

Message: 3 of 3

On Sep 23, 8:59 am, "Shaun Hurley" <jumpinghur...@yahoo.com> wrote:
> I am looking to plot my results as a piecewise function. I get an answer of something like:
>
> y = [1 3 -5 6 3]
>
> If I have an initial array of x = [0 1 2 3 4 5] does anyone know how I can plot x vs. y? I am looking for 5 discontinuous horizontal lines:
> y = 1 for x[0,1]
> y = 3 for x[1,2]
> y = -5 for x[2,3]
> y = 6 for x[3,4]
> y = 3 for x[4,5]
>
> Any ideas? Thank you!

help stairs

Tags for 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