Why does MATLAB terminate with no error message when using the UNIX redirection operator (<) to pass an input MATLAB file with a syntax error?
2 ビュー (過去 30 日間)
古いコメントを表示
When a MATLAB file contains a control structure that does not terminate with an 'end' statement before the end of file is reached, no syntax error message is displayed when passing the file to MATLAB via the UNIX redirection operator (<).
if 1 disp('if!\n');
else disp('else!\n');
Calling the above script 'testif.m' using the syntax below will cause MATLAB to exit without displaying either the script output or an error message.
matlab -nodisplay < testif.m
0 件のコメント
回答 (1 件)
Siddharth
2011 年 1 月 18 日
This issue is due to the way in which MATLAB interprets files that are passed to it via the redirection operator. MATLAB executes the file by reading each line as if it were typed at the MATLAB prompt. When it reaches the end of file, it continues to wait at the command prompt for the user to enter an ‘end’ statement; however, MATLAB exits once the end of the file is reached and before an 'end' is entered. It is the equivalent of entering each line of the M-file individually at the command line, then exiting MATLAB before typing the final ‘end’ statement. No error message is displayed in this case either. To work around this issue, call MATLAB using the following syntax:
matlab -nodisplay -r testif
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で MATLAB Compiler についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!