Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

MATLAB: killing a program

  1. Dec 12, 2005 #1

    I've been trying to figure this out for a bit and thought one of you might know the answer off the top of your head.

    I have an if-statement in my MATLAB program that error checks a matrix and vector size. I want the program to print an error message and then end the program (like a ctrl-c) if the error condition is satisfied. Something like this:

    Code (Text):
    if a~=b
    fprintf('STFU N00B');
    % other stuff
    where ?????????? is the function the would end the program. Does such a function exist, and if so, what is it?

    Thanks in advance.
    Last edited: Dec 12, 2005
  2. jcsd
  3. Dec 12, 2005 #2


    User Avatar
    Science Advisor

    STFU NOOB? Heh heh heh...That's funny. Sorry I can't help on the Matlab part.
  4. Dec 12, 2005 #3
    Code (Text):
    if a~=b
    fprintf('STFU N00B');
    error('u R not 1337')
    % other stuff
  5. Dec 12, 2005 #4


    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    if you are writing a function, your output variables have been defined, and you want them passed, you can also use the 'return' command.
  6. Dec 12, 2005 #5
    yes there is a breaker that ends the matlab exe...unfortunately i haven't played with matlab for 3 years.
  7. Dec 13, 2005 #6
    Thanks, Brad! That's exactly what I needed. LeBrad = awesome;

    And thanks to everyone else too
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

Similar Threads for MATLAB killing program Date
MATLAB: forces acting on an object Apr 6, 2018
MATLAB Matlab histogram Apr 4, 2018
MATLAB Sovling Bernoulli's differential equation in matlab? Apr 3, 2018
MATLAB Matlab-like software Mar 27, 2018
A Mathematical Analysis of Randy Johnson's bird killing fastball Jun 15, 2006