try/catch warning
4 次查看(过去 30 天)
显示 更早的评论
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...........
0 个评论
采纳的回答
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
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
更多回答(1 个)
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.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Entering Commands 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!