try/catch warning

조회 수: 20 (최근 30일)
DAD
DAD 2011년 10월 4일
편집: Guillaume 2018년 6월 19일
I got the warning message like this while used in MATLAB 2007.........
??? Warning: File: histfit1.m Line: 62 Column: 7
This try-catch syntax will continue to work in R2007a,
but may be illegal or may mean something different in future releases of MATLAB.
See Release Notes for MATLAB Version 7.4, "Warning Generated by try-catch" for details.
Please help me...........

채택된 답변

Walter Roberson
Walter Roberson 2011년 10월 4일
You didn't write histfit1, so don't worry about it. When you get to a version of MATLAB where the syntax used internally actually makes a difference, TMW will have changed their routine.
If it really bugs you, apply the solution in the release notes that the warning refers to. You can find that here
  댓글 수: 2
Walter Roberson
Walter Roberson 2011년 10월 4일
As my previous reply does not appear to have been satisfactory for you, I will point you to the documentation as how you can turn the warning off -- which will merely hide the warning rather than dealing with it, and will probably be a waste of time unless the warning is occurring over and over in a loop:
http://www.mathworks.com/help/techdoc/matlab_prog/f3-39022.html#f3-39056
See in particular
warning off last
DAD
DAD 2011년 10월 4일
sorry i never wrote histfit1 ........

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Hamid Moazed
Hamid Moazed 2018년 6월 19일
편집: Guillaume 2018년 6월 19일
For convenience here is the text (the link in above answer is broken):
To accommodate future changes in the MATLAB error-handling capabilities, there is a new restriction to the syntax of the try-catch block. When the first MATLAB statement that follows the try keyword consists of just a single term (e.g., A as opposed to A+B) occurring on the same line as the try, then that statement and the try keyword should be separated by a comma. For example, the line try A
should be written as either
try, A
or on two lines as
try
A
This affects only single-term statements. For example, the following statement continues to be valid:
try A+B
The same holds true for the catch keyword and a single-term statement following the keyword on the same line. A valid try-catch statement of this type should be composed as follows:
try, A, catch, B, end
If you omit the commas following try and/or catch, your code will continue to operate correctly. However, MATLAB will issue a warning: try statements, catch statements, end
Warning: This try-catch syntax will continue to work in R2007a, but may be illegal or may mean something different in future releases of MATLAB. As with previous releases, the recommended syntax for a try-catch block is as follows:
try
try_statements
catch
catch_statements
end
Note
Due to a bug in the R2007a release, the warning for a catch followed immediately by a single term is thrown as an error, even though the text of the message says that it is a warning.

카테고리

Help CenterFile Exchange에서 Data Type Identification에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by