Code Analyzer Misses Variables

I noticed that the code analyzer, at least in Matlab R2016b, misses variables named "TFR". For instance, in the following code, code analyzer marks TFR in the left hand side of the first line as unused, even though it appears just two lines later. The automatic highlighting also doesn't work. Suggestions?
[ERP, TFR] = prelim(cfg);
for i = 1:6
tmpTFR = TFR;
tmpTFR.powspctrm = squeeze(TFR.powspctrm(i,:,:,:));
tmpTFR.dimord = 'chan_freq_time';
figure
cfg = [];
cfg.parameter = 'powspctrm';
cfg.baseline = [-1 -0.1];
cfg.baselinetype = 'db';
cfg.showlabels = 'yes';
cfg.layout = 'CPC_vis_EEG_layout.mat';
ft_multiplotTFR(cfg, tmpTFR);
end

4 件のコメント

Matt J
Matt J 2018 年 7 月 23 日
Well, I think the solution is obvious. You shouldn't be using TFR as a variable name ;)
Nir Ofir
Nir Ofir 2018 年 7 月 23 日
I suppose :) I should have phrased the question differently: "Suggestions why it so?" rather than suggestions to what I could do to solve it...
Matt J
Matt J 2018 年 7 月 23 日
Looks like a bug to me. I don't see it in R2017b or R2018a. Can you upgrade?
Nir Ofir
Nir Ofir 2018 年 8 月 12 日
Thanks for your suggestion.

サインインしてコメントする。

回答 (1 件)

Steven Lord
Steven Lord 2018 年 7 月 23 日

1 投票

What's on the line between "[ERP, TFR] = prelim(cfg);" and "for i = 1:6" in your picture, the line covered by the Code Analyzer message? It looks like there's enough space for a blank line or one line of code.
If on that line you have code that assigned a value to TFR using non-subscripted indexing (TFR = something) then the Code Analyzer message would be correct as you would be overwriting the contents of that variable before using what prelim returned as its second output.

1 件のコメント

Nir Ofir
Nir Ofir 2018 年 8 月 12 日
Thank you. Just a blank line.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeGraph and Network Algorithms についてさらに検索

製品

リリース

R2016b

質問済み:

2018 年 7 月 23 日

コメント済み:

2018 年 8 月 12 日

Community Treasure Hunt

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

Start Hunting!

Translated by