What does the value of% # ok <SAGROW> in MATLAB mean?

I have met many MATLAB codes that have %#ok<SAGROW> . This comment is used in different circumstances, and I cannot understand what it means.

As an example:

 i = 1; flag = true; for l = 1:k while(flag==true) if(probs(i)~=0) leaves(l).val = i-1; %#ok<*SAGROW> leaves(l).zero = ''; leaves(l).one = ''; leaves(l).prob = probs(i); i = i + 1; flag = false; else i = i+1; flag = true; end end flag =true; end 

There are other links to this comment for instace:

+8
comments matlab
source share
3 answers

It suppresses mlint warnings. In this particular case, we are not talking about the preliminary distribution of the array.

mlint is one of the static code analysis tools that Matlab has. It finds possible errors and displays warnings.

Edit (1) : I just noticed that your question is about SAGROW , not AGROW . I could not find him. I assume this is the old / new mlint syntax.

+6
source share

General answer (for different values ​​in angle brackets):

Type msgid:SAGROW in Settings -> Code Analyzer.

For other msgid:<your-ok-msg-id> .

change the shortest path, 1. delete the comment, 2. read the tooltip of the code analyzer of the underlined code fragment.

+4
source share

I do not know about SAGROW , but AGROW means that the given array / vector / matrix <name> might be growing inside a loop. Consider preallocating for speed <name> might be growing inside a loop. Consider preallocating for speed .

+2
source share

All Articles