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:
question about ctrl+c

Subject: question about ctrl+c

From: dhuan Du

Date: 28 Apr, 2009 19:54:02

Message: 1 of 6

Hi, friends:

If i use ctrl+c to stop the program, could i check the values of the variables?
Thank you very much!

Subject: question about ctrl+c

From: ashish

Date: 28 Apr, 2009 20:13:02

Message: 2 of 6

"dhuan Du" <dupeony@gmail.com> wrote in message <gt7msq$99v$1@fred.mathworks.com>...
> Hi, friends:
>
> If i use ctrl+c to stop the program, could i check the values of the variables?
> Thank you very much!

If you are seeing continous values generated for hours or so, you will be able to see the values till you press cntrl+c , but it is stuck somewhere you will not see any values for that particular part of the program and the part following it.

Subject: question about ctrl+c

From: Steven Lord

Date: 28 Apr, 2009 21:17:04

Message: 3 of 6


"dhuan Du" <dupeony@gmail.com> wrote in message
news:gt7msq$99v$1@fred.mathworks.com...
> Hi, friends:
>
> If i use ctrl+c to stop the program, could i check the values of the
> variables?

No. Ctrl-C terminates the execution of your function and brings you back to
the >> prompt. There may be a delay between when you press Ctrl-C and when
the function terminates if MATLAB is waiting for a library that it's called
(like the BLAS or FFTW) to return control to it.

--
Steve Lord
slord@mathworks.com

Subject: question about ctrl+c

From: Matt Fig

Date: 28 Apr, 2009 21:56:01

Message: 4 of 6

"Steven Lord" <slord@mathworks.com> wrote in message <gt7roa$8d6$1@fred.mathworks.com>...
>
> "dhuan Du" <dupeony@gmail.com> wrote in message
> news:gt7msq$99v$1@fred.mathworks.com...
> > Hi, friends:
> >
> > If i use ctrl+c to stop the program, could i check the values of the
> > variables?
>
> No. Ctrl-C terminates the execution of your function and brings you back to
> the >> prompt. There may be a delay between when you press Ctrl-C and when
> the function terminates if MATLAB is waiting for a library that it's called
> (like the BLAS or FFTW) to return control to it.
>
> --
> Steve Lord
> slord@mathworks.com
>


But Steve, the OP did not specify that he was running a function, just a program. A program could be a script to some people.

To the OP: If you are running a script, you will be able to see whatever values existed at the time of the ctr-c. If you are running a function, they will be lost. For example, if this is put into a script M-File and run until ctr-c is invoked, you can see the values of the variables by typing them at the command line, or in general by using whos.


ii = 1;
while ii
   A = rand(round(ii)); % Don't let this run too long!!
   ii = ii+.00001;
end

Subject: question about ctrl+c

From: Steven Lord

Date: 29 Apr, 2009 13:59:29

Message: 5 of 6


"Matt Fig" <spamanon@yahoo.com> wrote in message
news:gt7u1h$7u8$1@fred.mathworks.com...
> "Steven Lord" <slord@mathworks.com> wrote in message
> <gt7roa$8d6$1@fred.mathworks.com>...
>>
>> "dhuan Du" <dupeony@gmail.com> wrote in message
>> news:gt7msq$99v$1@fred.mathworks.com...
>> > Hi, friends:
>> >
>> > If i use ctrl+c to stop the program, could i check the values of the
>> > variables?
>>
>> No. Ctrl-C terminates the execution of your function and brings you back
>> to
>> the >> prompt. There may be a delay between when you press Ctrl-C and
>> when
>> the function terminates if MATLAB is waiting for a library that it's
>> called
>> (like the BLAS or FFTW) to return control to it.
>>
>> --
>> Steve Lord
>> slord@mathworks.com
>>
>
>
> But Steve, the OP did not specify that he was running a function, just a
> program. A program could be a script to some people.

True, true. I mainly use scripts for "one-off" examples or for
experimenting with a function; most of my "programs" are functions so I
assumed that's what the OP was using.

> To the OP: If you are running a script, you will be able to see whatever
> values existed at the time of the ctr-c. If you are running a function,
> they will be lost. For example, if this is put into a script M-File and
> run until ctr-c is invoked, you can see the values of the variables by
> typing them at the command line, or in general by using whos.
>
>
> ii = 1;
> while ii
> A = rand(round(ii)); % Don't let this run too long!!
> ii = ii+.00001;
> end

Matt is correct.

One thing I'd suggest, since you said either earlier in this thread or in
another thread that this program has been running for a while, is to debug
your code with a small, short version of the problem you're trying to solve
until you're reasonably sure that it's working correctly, and then let it
rip on your larger problem. For instance, if you're trying to solve an ODE
from t = 0 to t = 100000, start off by solving the ODE from t = 0 to t = 1
or t = 10 first, to make sure that it's working correctly -- _then_ you set
it loose on the whole interval.

--
Steve Lord
slord@mathworks.com

Subject: question about ctrl+c

From: dhuan Du

Date: 29 Apr, 2009 18:23:02

Message: 6 of 6

Thanks for all of the suggestions.

Yes, I run a program with some functions. After i try ctrl+c I can check the variable in the main program but not the variables in the functions.

Also, I will run a small case and see if there is any bugs to make a endless loop.


"Steven Lord" <slord@mathworks.com> wrote in message <gt9mfr$clh$1@fred.mathworks.com>...
>
> "Matt Fig" <spamanon@yahoo.com> wrote in message
> news:gt7u1h$7u8$1@fred.mathworks.com...
> > "Steven Lord" <slord@mathworks.com> wrote in message
> > <gt7roa$8d6$1@fred.mathworks.com>...
> >>
> >> "dhuan Du" <dupeony@gmail.com> wrote in message
> >> news:gt7msq$99v$1@fred.mathworks.com...
> >> > Hi, friends:
> >> >
> >> > If i use ctrl+c to stop the program, could i check the values of the
> >> > variables?
> >>
> >> No. Ctrl-C terminates the execution of your function and brings you back
> >> to
> >> the >> prompt. There may be a delay between when you press Ctrl-C and
> >> when
> >> the function terminates if MATLAB is waiting for a library that it's
> >> called
> >> (like the BLAS or FFTW) to return control to it.
> >>
> >> --
> >> Steve Lord
> >> slord@mathworks.com
> >>
> >
> >
> > But Steve, the OP did not specify that he was running a function, just a
> > program. A program could be a script to some people.
>
> True, true. I mainly use scripts for "one-off" examples or for
> experimenting with a function; most of my "programs" are functions so I
> assumed that's what the OP was using.
>
> > To the OP: If you are running a script, you will be able to see whatever
> > values existed at the time of the ctr-c. If you are running a function,
> > they will be lost. For example, if this is put into a script M-File and
> > run until ctr-c is invoked, you can see the values of the variables by
> > typing them at the command line, or in general by using whos.
> >
> >
> > ii = 1;
> > while ii
> > A = rand(round(ii)); % Don't let this run too long!!
> > ii = ii+.00001;
> > end
>
> Matt is correct.
>
> One thing I'd suggest, since you said either earlier in this thread or in
> another thread that this program has been running for a while, is to debug
> your code with a small, short version of the problem you're trying to solve
> until you're reasonably sure that it's working correctly, and then let it
> rip on your larger problem. For instance, if you're trying to solve an ODE
> from t = 0 to t = 100000, start off by solving the ODE from t = 0 to t = 1
> or t = 10 first, to make sure that it's working correctly -- _then_ you set
> it loose on the whole interval.
>
> --
> Steve Lord
> slord@mathworks.com
>

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