2014-10-27 79 views
2

我一直在使用quit命令關閉MATLAB。然而,最近我發現exit是相同的,除了它可以節省您的Editor window,這對我真的很有幫助。一旦關閉MATLAB,Quit和Exit有什麼區別?

MATLAB對exit求助說:

It performs the same as quit and takes the same termination options.

他們是相同的,但我看到他們有一些差異。

Q1:還有其他的區別嗎?

Q2:哪一個應該用來關閉MATLAB?

+2

很多語言都有別名功能的不同,可能是由歷史原因在產品開發期間從一個切換到另一個。例如,在php中,'join'和'implode'是相同的,'echo'和'print'也是。 '我發現退出是一樣的,除了它保存你的編輯器窗口,這對我很有幫助'不要在文檔中看到它。如果存在,你可以從'finish.m'中保存。 – Cheery 2014-10-27 07:04:36

回答

4

A2:所有,它們的功能是相同的

A1:沒有,沒有記載差異


2.2 Quitting 
============ 

-- Built-in Function: exit (STATUS) 
-- Built-in Function: quit (STATUS) 

    Exit the current session. If the optional integer value 
    STATUS is supplied, pass that value to the operating system as the exit status. 
    The default STATUS value is zero. 

-- Built-in Function: atexit (FUNCT) 
-- Built-in Function: atexit (FUNCT, FLAG) 

    Register a function to be called when exits. For example, 

      function last_words()      %% .DEF 
        disp ("Bye bye"); 
      endfunction 

      atexit ("last_words");     %% .REG last_words() via atexit() 

    will print the message "Bye bye" when session exits. 

    The additional argument FLAG will register or unregister FUNCT from 
    the list of functions to be called when session exits. If FLAG is 
    true, the function is registered, and if FLAG is false, it is 
    unregistered. For example, after registering the function 
    `last_words()' above, 

      atexit ("last_words", false);    %% !REG remove registered FUNCT 

    will remove the function from the list and session will not call 
    `last_words' when it exits. 

    Note that `atexit' only removes the first occurrence of a function 
    from the list, so if a function was placed in the list multiple 
    times with `atexit', it must also be removed from the list 
    multiple times. 
+2

雖然你的直接答案A1和A2都很好,但你引用的文檔是Octave,而不是MATLAB,並且與問題無關。例如,在MATLAB中沒有'atexit'這樣的函數。 – 2014-10-27 11:26:34