Break command (MATLAB)

Posted on 2007-07-31
Last Modified: 2016-02-10
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
Question by:Pinpointsystems
    1 Comment
    LVL 1

    Accepted Solution

    you can use the Keypress-Function of a figure window.
    Here's an example:

    function testbreak
    % Exits an infinite loop on keypress
    pause(1); % to give the figure window time to open
    set(f, 'KeyPressFcn', @testend);

    function testend(src, event)


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Suggested Solutions

    Title # Comments Views Activity
    Adapt this command to show who installed 29 99
    tenRun challenge 28 67
    scoresSpecial  challenge 13 34
    bunnyEars2 challenge 6 46
    Windows Script Host (WSH) has been part of Windows since Windows NT4. Windows Script Host provides architecture for building dynamic scripts that consist of a core object model, scripting hosts, and scripting engines. The key components of Window…
    Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
    The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
    The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

    759 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

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now