Got Questions? Get Answers.
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:
Step input as i drive

Subject: Step input as i drive

From: Faraz Afzal

Date: 12 Mar, 2009 17:27:01

Message: 1 of 7

Hello everyone,

I wanted to have 2000 discrete steps of time 0 to18 seconds done by using linspace(0,18,2000).

Now I need a step input such that it uses the time vector above and must generate step when time is 10 seconds ..This step input infact is a negative 2 (i.e. -2 step)..

so from time 0 to 10 seconds = 0
          time 10 to 18 seconds = -2
.I can do it in simulink but i have to work on a data in my workspace.

I hope I explained my problem...
Secondly i want to plot this step input and its response on a same plot...what should i do. I dont want subplots anywayz..
 Good day!!

Subject: Step input as i drive

From: Srikanth

Date: 12 Mar, 2009 18:56:08

Message: 2 of 7

On Mar 12, 10:27=A0am, "Faraz Afzal" <farazaf...@gmail.com> wrote:
> Hello everyone,
>
> I wanted to have 2000 discrete steps of time 0 to18 seconds done by using=
 linspace(0,18,2000).
>
> Now I need a step input such that it uses the time vector above and must =
generate step when time is 10 seconds ..This step input infact is a negativ=
e 2 (i.e. -2 step)..
>
> so from time 0 to 10 seconds =A0=3D =A00
> =A0 =A0 =A0 =A0 =A0 time 10 to 18 seconds =A0=3D -2
> .I can do it in simulink but i have to work on a data in my workspace.

Several ways - from simulink, you can output the data to workspace
using a To Workspace sink.

Alternatively, you could generate the plot as
y=3Dlinspace(0,18,2000);
y(y<10)=3D0;
y(y>10)=3D-2;
(Or just concatenate two linspaces, but you'll have to compute the
number of points by taking the ratio of 10 and 18, which might not
divide your total number of

> I hope I explained my problem...
> Secondly i want to plot this step input and its response on a same plot..=
.what should i do. I dont want subplots anywayz..
> =A0Good day!!

look for hold on or
try plot(1:2000,input,1:2000,output)

hth

Subject: Step input as i drive

From: Faraz Afzal

Date: 13 Mar, 2009 01:27:01

Message: 3 of 7

Srikanth <skt@xdtech.com> wrote in message <2873f72e-6344-46e2-af6d-7fde55641c78@k29g2000prf.googlegroups.com>...
> On Mar 12, 10:27=A0am, "Faraz Afzal" <farazaf...@gmail.com> wrote:
> > Hello everyone,
> >
> > I wanted to have 2000 discrete steps of time 0 to18 seconds done by using=
> linspace(0,18,2000).
> >
> > Now I need a step input such that it uses the time vector above and must =
> generate step when time is 10 seconds ..This step input infact is a negativ=
> e 2 (i.e. -2 step)..
> >
> > so from time 0 to 10 seconds =A0=3D =A00
> > =A0 =A0 =A0 =A0 =A0 time 10 to 18 seconds =A0=3D -2
> > .I can do it in simulink but i have to work on a data in my workspace.
>
> Several ways - from simulink, you can output the data to workspace
> using a To Workspace sink.
>
> Alternatively, you could generate the plot as
> y=3Dlinspace(0,18,2000);
> y(y<10)=3D0;
> y(y>10)=3D-2;
> (Or just concatenate two linspaces, but you'll have to compute the
> number of points by taking the ratio of 10 and 18, which might not
> divide your total number of
>
> > I hope I explained my problem...
> > Secondly i want to plot this step input and its response on a same plot..=
> .what should i do. I dont want subplots anywayz..
> > =A0Good day!!
>
> look for hold on or
> try plot(1:2000,input,1:2000,output)
>
> hth

unfortunately it does not helps, or may b i dont know how should i handle this.

When i use sink, to workspace, with a step that starts at 10 seconds with value -2 i get two variable in workspace called tout and simout.
now when i plot them i never see a step as i can see them in simulink scope. it just shows me a linear line thats it.. for tout ...

Am i doing right or still missing sumthing.???how should i now plot them from workspace.??

Hope i get solution.!!

Subject: Step input as i drive

From: Faraz Afzal

Date: 13 Mar, 2009 10:07:01

Message: 4 of 7

and this 3Dlinspace is not recognized by matlab......there is nothing of this type in documentation...only linspace....i tried to copied the things as u wwrote but even they did not worked...

do u have any other idea?

Srikanth <skt@xdtech.com> wrote in message <2873f72e-6344-46e2-af6d-7fde55641c78@k29g2000prf.googlegroups.com>...
> On Mar 12, 10:27=A0am, "Faraz Afzal" <farazaf...@gmail.com> wrote:
> > Hello everyone,
> >
> > I wanted to have 2000 discrete steps of time 0 to18 seconds done by using=
> linspace(0,18,2000).
> >
> > Now I need a step input such that it uses the time vector above and must =
> generate step when time is 10 seconds ..This step input infact is a negativ=
> e 2 (i.e. -2 step)..
> >
> > so from time 0 to 10 seconds =A0=3D =A00
> > =A0 =A0 =A0 =A0 =A0 time 10 to 18 seconds =A0=3D -2
> > .I can do it in simulink but i have to work on a data in my workspace.
>
> Several ways - from simulink, you can output the data to workspace
> using a To Workspace sink.
>
> Alternatively, you could generate the plot as
> y=3Dlinspace(0,18,2000);
> y(y<10)=3D0;
> y(y>10)=3D-2;
> (Or just concatenate two linspaces, but you'll have to compute the
> number of points by taking the ratio of 10 and 18, which might not
> divide your total number of
>
> > I hope I explained my problem...
> > Secondly i want to plot this step input and its response on a same plot..=
> .what should i do. I dont want subplots anywayz..
> > =A0Good day!!
>
> look for hold on or
> try plot(1:2000,input,1:2000,output)
>
> hth

Subject: Step input as i drive

From: Srikanth

Date: 13 Mar, 2009 21:49:41

Message: 5 of 7


> unfortunately it does not helps, or may b i dont know how should i handle=
 this.
>
> When i use sink, to workspace, with a step that starts at 10 seconds with=
 value -2 i get two variable in workspace =A0called tout and simout.
> now when i plot them i never see a step as i can see them in simulink sco=
pe. it just shows me a linear line thats it.. for tout ...
>
tout is the time series of the simulation. simout is the default name
for the values that feed into the "To Workspace" block - which, by
default are stored as structures. In the "To Workspace" block, change
the storage into array, rather than structure.

Subject: Step input as i drive

From: Srikanth

Date: 13 Mar, 2009 21:52:38

Message: 6 of 7

On Mar 13, 3:07=A0am, "Faraz Afzal" <farazaf...@gmail.com> wrote:
> and this 3Dlinspace is not recognized by matlab......there is nothing of =
this type in documentation...only linspace....i tried to copied the things =
as u wwrote but even they did not worked...
>

The command I typed in the previous message works fine on R2008a, I am
using linspace, not 3Dlinspace (which doesn't exist).
The commands I used generate a step from 0 to -2 at t=3D10 seconds,
which I believe is what you wanted?

Subject: Step input as i drive

From: Walter Roberson

Date: 14 Mar, 2009 07:33:00

Message: 7 of 7

Faraz Afzal wrote:
> and this 3Dlinspace is not recognized by matlab.

Any time in a posting here that you see 3D, look to see if that
3D is immediately after an equals-sign. If so, then chances are excellent
that you will find that the person who posted the code posted from
Google Groups. Google Groups encodes plain equal-signs as
the combination equal-sign three capital-D . This is, in my opinion (and
that I could cite technical references) a bug, but Google unfortunately
considers it a feature.

In short: if you see code that has 3D right after an assignment, you
should probably delete the 3D.

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