?
Solved

Break command (MATLAB)

Posted on 2007-07-31
2
Medium Priority
?
14,901 Views
Last Modified: 2016-02-10
hi,
i'm writing a matlab program to stream in live data from an external instrument, record it, plot it and send it of as an input for further processing. i'm using infinte looping in my program to achieve live streaming of the data into matlab but i'm not able to break or stop the program in the middle. is there a break command that we can use to come out of the loop when the program is running by pressing a single key or aythin else like its done in C++.

can anyone help me out with this
0
Comment
Question by:Pinpointsystems
1 Comment
 
LVL 1

Accepted Solution

by:
ThorstenKoch earned 2000 total points
ID: 19692773
Hi,
you can use the Keypress-Function of a figure window.
Here's an example:

function testbreak
%
% Exits an infinite loop on keypress
%
f=figure();
pause(1); % to give the figure window time to open
running=true;
set(f, 'KeyPressFcn', @testend);
while(running)
    fprintf('Running\n');
    pause(0.0001);
end

function testend(src, event)
if(event.Character=='q')
    running=false;
end
end

end
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Navigation is an important part of web design from a usability perspective. But it is often a pain when it comes to a developer’s perspective. By navigation, it often means menuing. This is less theory and more practical of how to get a specific gro…
Having just graduated from college and entered the workforce, I don’t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back to…R.   So …
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Suggested Courses

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question