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

Question !!

[Subject Prev][Subject Next][Thread Prev][Thread Next]
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
begins.

Any suggestions?
 
Thanx in advance for your time!!
 
function run(ang)
 
[x,y,z]=sphere(20);
R=Ry(ang);
[x,y,z]=transform(x,y,z,R);
l=[0,0,1.3;0,0,-1.3];
a=l(:,1);
b=l(:,2);
d=l(:,3);
[a,b,d]=transform(a,b,d,R);
n=[0,0,1.2;0,0,-1.2];
R=Rz(pi/18);
stop='START';
i=1;
hold;
while stop=='START';
    [x,y,z]=transform(x,y,z,R);
    [a,b,d]=transform(a,b,d,R);
    colormap([127/255 1 212/255]);
    surf(x,y,z);
    axis equal;
    axis([-2 2 -2 2 -2 2]);
    hold;
    axis off;
    plot3(a,b,d,'r');
    plot3(n(:,1),n(:,2),n(:,3));
    view(0,0);
    Q(i)=getframe;
    hold;
    i=i+1;
 end;