How to execute 2 functions simultaneously in the same loop on a GUI
Ältere Kommentare anzeigen
I have a program that uses DAQ to generate signals. I have a timer that runs between a specific range. But I want the timer to keep running even if the signal is generating. What I mean, is that the code that generates the signal has its own time... So when the period of generation is done, my timer restarts where it was.
Example: while(something) time = time + 1; pause(1);
if time == 1 generate signal code (for 5 seconds); end; end;
after generating is finished, time = 2, =3, etc. But I want time to keep running while generating signal.
Any idea? should I use global, persistent variable for time?
3 Kommentare
Salaheddin Hosseinzadeh
am 29 Mai 2015
Hi Adam,
What does this have to do with a persistent variable? If you're leaving a function and returning back to it and you don't want to lose the previous data you can use persistent.
I don't quite understand your problem at this point. Could you explain more maybe someone will be give you an advice.
BTW, is time an internal MATLAB command? or you defined it as a variable?! I think it is a reserved name.
Thanks
Adam Taher
am 29 Mai 2015
Bearbeitet: Adam Taher
am 29 Mai 2015
Salaheddin Hosseinzadeh
am 29 Mai 2015
Ok Adam, that's a bit better now!
Generally that's not a good way of keeping the track of time. you can make the while loop running. you can either make a timer object, or even make it easier and use tic toc commands
tic
toc
Anyhow, tic toc will keep the track of time for you while another code is running ;)
Good luck!
Antworten (1)
Salaheddin Hosseinzadeh
am 29 Mai 2015
Ok Adam, that's a bit better now!
Generally that's not a good way of keeping the track of time. you can make the while loop running. you can either make a timer object, or even make it easier and use tic toc commands
tic
toc
Anyhow, tic toc will keep the track of time for you while another code is running ;)
Good luck!
1 Kommentar
Salaheddin Hosseinzadeh
am 29 Mai 2015
BTY you can't use
if toc == 5
you probably have to go with
if toc >= 5
Kategorien
Mehr zu MATLAB Coder finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!