Return to index: [Subject] [Thread] [Date] [Author]

Re: Question !!

[Subject Prev][Subject Next][Thread Prev][Thread Next]
i don't know much about matlab but i have used other programming languages, here are my 2 suggestions:
1.  embed a statement inside your while loop (probably near where you are incrementing your counter) that looks for the current state of the "stop" button.  you may not be able to get this exactly where you want it but it would be within 1 iteration of the loop (as opposed to an infinite loop?).
2.  rewrite / rethink how this program works.  it seems strange to set up a function and then require the user to stop it while the function is being executed.  if you are trying to "converge" on a solution, maybe you can ask the user how many iterations he would like to use (then change the while statement to a "for" statement) or ask the user what is an expectable percentage to be within (then embed an error checking function into the while statement).
good luck, hth
----- Original Message -----
Sent: March 08, 2002 10:37 AM
Subject: Question !!

Ladies and Gentlemn,
I'm trying to finish my Technical Report and am having
some trouble writing code. I am a pitiful code writer. I'm using MATLAB and
it's object orientated.

Attached is a text file of my function 'run'. I'm building a Graphical User
Interface in MATLAB and have 3 basic buttons that make it work:

1) a Slider - allows user input of an angle and sets the value = 'ang'.

2) the Start button - calls the function 'run' (attached) using the value
previously determined for 'ang'

3) the Stop button - will someday STOP my program from running.

I'm trying to find a way of stoping the loop within the function 'run' from
executing when the 'Stop' button is clicked. I'm not sure what to do and and
I'm not sure if you need to know MATLAB to figure that out.

Right now my function contains a loop and runs as long as stop = 'START'. I
define this outside the loop. While the loop is running, I want to click the
Stop button on my GUI and reset stop = 'STOP'. I can do this within the code
of the button but it doesn't change the value already set before the loop

Any suggestions?
Thanx in advance for your time!!
function run(ang)
while stop=='START';
    colormap([127/255 1 212/255]);
    axis equal;
    axis([-2 2 -2 2 -2 2]);
    axis off;