1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
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
    Hi

    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');
    ???????????
    end
    % 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

    FredGarvin

    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')
    end
    % other stuff
     
  5. Dec 12, 2005 #4

    enigma

    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
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?



Similar Discussions: MATLAB: killing a program
  1. Matlab programming (Replies: 0)

  2. Programming in Matlab (Replies: 4)

Loading...