|
|
Re: How can you enlarge a matrix by adding zeroes
Posted:
Jun 18, 2012 10:21 AM
|
|
"dpb" <none@non.net> wrote in message news:jrihne$ncn$1@speranza.aioe.org... > On 6/16/2012 11:16 AM, Nasser M. Abbasi wrote: > ... > >> We as users, we have to assume the Matlab engineers who added this >> message to the code analyzer had a good reason to do it. They did >> not add it just for for the fun of it. > ... > > OK, I've done an extensive perusal of the online doc's for the last > release and I can find no hints of TMW suggesting to write matrices w/o > the brackets for performance in any situation.
Try this little experiment in the Command Window. You will receive warnings from the DBSTOP calls, but that's to be expected.
http://www.mathworks.com/help/techdoc/ref/dbstop.html
"If file is not a MATLAB code file (for instance, it is a built-in or MDL-file), then MATLAB issues a warning. MATLAB cannot stop in the file, so it pauses before executing the file."
dbstop in horzcat dbstop in vertcat a = [5]
Note that MATLAB DOES call the built-in concatenation routine here, since you're using []. Whether or not it calls the built-in concatenation routines in a function file depends on how old a version of MATLAB you're using, I think. The parser may be smart enough in later releases to avoid the unnecessary call to the built-in concatenation routine since it can tell that the built-in routine will be called. Code Analyzer does _static_ analysis of the code; the parser is not limited to static analysis when running the code.
Granted, the concatenation routine doesn't have to DO much or anything in this case, so it may not seem like a big deal. But consider doing this inside a loop that iterates millions of times; the tiny overhead of calling the built-in function may add up.
> The links to parentheses and brackets have essentially identical > documentation as I have here--it says 'help paren' has more info on > parentheses but I can't do that except locally. > > I suppose it's possible that there's where the guidance is hidden but I > seriously doubt it says anything of the sort there, either. > > So, I think the recommendation is simply an artifact of the code analyzer > nobody has ever questioned seriously as to the validity/reason for it. > Otherwise one has to presume there's a real reason for special-casing the > specific case and if so it's a significant oversight in the documentation > that it isn't discussed. > > $0.025, imo, ymmv, etc., etc., etc., ... > > Maybe S Lord will stumble upon the argu^h^h^h^hdiscussion and can comment > on the validity/significance of the analyzer and what applications it is > intended to address.
If the parser has gotten smart enough, perhaps the particular message that you and Bruno have been "discussing" is no longer necessary for functions or classdef files. I'll ask the Code Analyzer developers to investigate and determine if that message can be removed.
-- Steve Lord slord@mathworks.com To contact Technical Support use the Contact Us link on http://www.mathworks.com
|
|