From: Jón Bergsteinsson on
Hi all

Eh, I got a headache few hours ago just because I haven't figure this out yet. I've been trying all my best to solve this problem without making any message on this board, but here it goes.

The only thing I've been trying to do is to make a timer,counter or anything that counts up to 5 minutes, when I press a button in my GUI(no worries I've got the GUI under control, or at least I think :).

When I press the button, the timer should start counting up to 300 seconds and while he is counting a while loop should be running, which is reading on my comport and updating a plot.

I don't want the user to be able to set how long the time should be. This is supposed to be a 5 min period of recording from a serial port.

I've been reading alot about the timer and clock, and the now function and I feel like I'm complicating everything too much by setting too many functions, delays or blah.

I would like the code to look something like this

Starttimer(5min)

while timer running == true
read port
plot continously
end

How do I do this?
From: Jan Simon on
Dear Jón!

> I would like the code to look something like this
>
> Starttimer(5min)
>
> while timer running == true
> read port
> plot continously
> end

finalTime = datenum(clock + [0, 0, 0, 0, 5, 0]);
while datenum(clock) < finalTime
read port
plot continously
end

Kind regards, Jan
From: Jón Bergsteinsson on
"Jan Simon" <matlab.THIS_YEAR(a)nMINUSsimon.de> wrote in message <ht1hd4$r5q$1(a)fred.mathworks.com>...
> Dear Jón!
>
> > I would like the code to look something like this
> >
> > Starttimer(5min)
> >
> > while timer running == true
> > read port
> > plot continously
> > end
>
> finalTime = datenum(clock + [0, 0, 0, 0, 5, 0]);
> while datenum(clock) < finalTime
> read port
> plot continously
> end
>
> Kind regards, Jan

Thanks for that, I had tried to use the clock as a method but I didn't quite figure out how I could use it.
Thanks for that, it works!
 | 
Pages: 1
Prev: 3d plot rotation
Next: Surface Extrapolation