Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I disable Code Analyzer warnings in the MATLAB editor?

I have some prototype MATLAB code that is not required to be very fast.

An array used in the code grows in size, and MATLAB Code Analyzer displays the warning "consider preallocating for speed" in the MATLAB editor. However, I can't know the final size of the array because a decision is taken during its growing process, and I therefore don't wish to preallocate it.

How can I disable the "consider preallocating for speed" warning displayed by MATLAB Code Analyzer in the MATLAB editor?

like image 622
Suzan Cioc Avatar asked Dec 12 '22 13:12

Suzan Cioc


1 Answers

With the Editor open, you could right-click the orange squiggly line and select suppress "<warning msg>" on this line. This will insert a comment %#ok<SAGROW> telling MATLAB Code Analyzer to suppress this warning:

p = [];
for i=1:1000
    p(i) = i; %#ok<SAGROW>
end
like image 159
Amro Avatar answered Jan 17 '23 16:01

Amro