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 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (1)
Siddharth
il 18 Gen 2011
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 Commenti
Vedere anche
Categorie
Scopri di più su MATLAB Compiler in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!