0
for m = 1:4000
    UPDATE_multiDM(driver_info, amplitudes2);
    UPDATE_multiDM(driver_info, amplitudes1);
end

Is it possible to execute this line --> set(deviceObj.Acquisition(1), 'State', 'stop'); simultaneously with the for loop above. So during the 1:4000 I will be able to execute this line

The line will stop a oscilloscope from running while the the for loop continues to run until it reaches the end

  • 1
    matlab cannot run two commands at once. Unless there is a way to have the OS perform one of the two commands or run two matlab sessions, this is impossible. See [here](http://www.mathworks.com/matlabcentral/newsreader/view_thread/142083), [here](http://www.mathworks.com/matlabcentral/answers/2081-how-to-execute-two-matlab-scripts-simultaneously) and [here](http://stackoverflow.com/questions/4410339/how-can-i-parallelize-input-and-display-in-matlab). – Raab70 Apr 30 '14 at 20:36
  • When exactly should that second command be started? At the same time with the loop, or sometime during the loop? How long does the loop need to execute, how long the second command? – A. Donda May 01 '14 at 00:45

1 Answers1

0

MATLAB cannot run two processes at the same time (I'm not mentioning Parallel Toolbox now).

If you don't want to run separate session, you can temporary stop the loop, run the command and continue execution.

You can stop by timer (see timer class) or use a simple figure with KeyPressFcn callback. See here, for an example. That example will stop the execution, but you can if statement inside your for-loop to stop it temporarily.

yuk
  • 19,098
  • 13
  • 68
  • 99