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:
Apply Dealy in a simple for-loop

Subject: Apply Dealy in a simple for-loop

From: Nehal

Date: 23 Nov, 2010 06:12:03

Message: 1 of 7

I have a simple for loop. For example,

A = 1;
   for i = 1:100
   A = A+1;
end

this shows a result promptly. But I want to put some delay before increasing the value of A each time. For example I want to increase A or I want to run the loop every 0.25 sec.

that means my function will be something like this:

A = 1;
   for i = 1:100
   A = A+1;
% 0.25 second delay
% then the loop continues
end

is it possible..? can anyone please help me..?

Subject: Apply Dealy in a simple for-loop

From: Nehal

Date: 23 Nov, 2010 06:37:09

Message: 2 of 7

"Nehal " <arnab620@yahoo.com> wrote in message <icflvj$9uj$1@fred.mathworks.com>...
> I have a simple for loop. For example,
>
> A = 1;
> for i = 1:100
> A = A+1;
> end
>
> this shows a result promptly. But I want to put some delay before increasing the value of A each time. For example I want to increase A or I want to run the loop every 0.25 sec.
>
> that means my function will be something like this:
>
> A = 1;
> for i = 1:100
> A = A+1;
> % 0.25 second delay
> % then the loop continues
> end
>
> is it possible..? can anyone please help me..?


sorry.. typing mistake... it should be delay.. not dealy
I simply want to add time delay in my for-loop.

Subject: Apply Dealy in a simple for-loop

From: Walter Roberson

Date: 23 Nov, 2010 06:48:37

Message: 3 of 7

On 23/11/10 12:37 AM, Nehal wrote:
> "Nehal " <arnab620@yahoo.com> wrote in message
> <icflvj$9uj$1@fred.mathworks.com>...
>> I have a simple for loop. For example,
>>
>> A = 1;
>> for i = 1:100
>> A = A+1;
>> end
>>
>> this shows a result promptly. But I want to put some delay before
>> increasing the value of A each time. For example I want to increase A
>> or I want to run the loop every 0.25 sec.

See pause()

Subject: Apply Dealy in a simple for-loop

From: Greg Heath

Date: 23 Nov, 2010 07:13:42

Message: 4 of 7

On Nov 23, 1:48 am, Walter Roberson <rober...@hushmail.com> wrote:
> On 23/11/10 12:37 AM, Nehal wrote:
>
> > "Nehal " <arnab...@yahoo.com> wrote in message
> > <icflvj$9u...@fred.mathworks.com>...
> >> I have a simple for loop. For example,
>
> >> A = 1;
> >> for i = 1:100
> >> A = A+1;
> >> end
>
> >> this shows a result promptly. But I want to put some delay before
> >> increasing the value of A each time. For example I want to increase A
> >> or I want to run the loop every 0.25 sec.
>
> See pause()

help pause
doc pause

Greg

Subject: Apply Dealy in a simple for-loop

From: Nehal

Date: 23 Nov, 2010 07:23:03

Message: 5 of 7

Walter Roberson <roberson@hushmail.com> wrote in message <9tJGo.34548$sK1.9229@newsfe21.iad>...
> On 23/11/10 12:37 AM, Nehal wrote:
> > "Nehal " <arnab620@yahoo.com> wrote in message
> > <icflvj$9uj$1@fred.mathworks.com>...
> >> I have a simple for loop. For example,
> >>
> >> A = 1;
> >> for i = 1:100
> >> A = A+1;
> >> end
> >>
> >> this shows a result promptly. But I want to put some delay before
> >> increasing the value of A each time. For example I want to increase A
> >> or I want to run the loop every 0.25 sec.
>
> See pause()

thank you...
one more question... do I need to enable pause? coz I have found a line in matlab help. It says: Pausing must be enabled for this to take effect.

so do I need to enable it before using it or I can just use:
pause (0.25);

Subject: Apply Dealy in a simple for-loop

From: Walter Roberson

Date: 23 Nov, 2010 15:54:42

Message: 6 of 7

On 23/11/10 1:23 AM, Nehal wrote:

> thank you...
> one more question... do I need to enable pause? coz I have found a line
> in matlab help. It says: Pausing must be enabled for this to take effect.
>
> so do I need to enable it before using it or I can just use:
> pause (0.25);

Pausing is enabled by default.

Subject: Apply Dealy in a simple for-loop

From: Nehal

Date: 23 Nov, 2010 16:52:04

Message: 7 of 7

Walter Roberson <roberson@hushmail.com> wrote in message <6tRGo.39962$z41.34516@newsfe05.iad>...
> Pausing is enabled by default.

thank you.. :)

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