![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1140820/image.jpeg)
配列インデックスのエラーメッセージについて
8 views (last 30 days)
Show older comments
下記のようなプログラムで、エラーメッセージが出ます。どのように直せば良いですか。
if ~isnan(t_TRGe_V(1))==1
for t = 2:length(t_TRGe_V)-1
pFp1_V = [pFp1_V;Fp1_V(t_TRGe_V(t)+analwin_eeg_V(1):t_TRGe_V(t)+analwin_eeg_V(2))'];
pFp2_V = [pFp2_V;Fp2_V(t_TRGe_V(t)+analwin_eeg_V(1):t_TRGe_V(t)+analwin_eeg_V(2))'];
pFC3_V = [pFC3_V;FC3_V(t_TRGe_V(t)+analwin_eeg_V(1):t_TRGe_V(t)+analwin_eeg_V(2))'];
pFC4_V = [pFC4_V;FC4_V(t_TRGe_V(t)+analwin_eeg_V(1):t_TRGe_V(t)+analwin_eeg_V(2))'];
pO1_V = [pO1_V;O1_V(t_TRGe_V(t)+analwin_eeg_V(1):t_TRGe_V(t)+analwin_eeg_V(2))'];
pO2_V = [pO2_V;O2_V(t_TRGe_V(t)+analwin_eeg_V(1):t_TRGe_V(t)+analwin_eeg_V(2))'];
pP5_V = [pP5_V;P5_V(t_TRGe_V(t)+analwin_eeg_V(1):t_TRGe_V(t)+analwin_eeg_V(2))'];
pP6_V = [pP6_V;P6_V(t_TRGe_V(t)+analwin_eeg_V(1):t_TRGe_V(t)+analwin_eeg_V(2))'];
end
配列インデックスは正の整数または logical 値でなければなりません。
エラー: EEG_test (行 82)
pFp1_V = [pFp1_V;Fp1_V(t_TRGe_V(t)+analwin_eeg_V(1):t_TRGe_V(t)+analwin_eeg_V(2))'];
0 Comments
Accepted Answer
Kojiro Saito
on 30 Sep 2022
MATLABのエディターで該当行 (EEG_test.mの82行目)の行番号をマウスでクリックしてブレークポイントを設定してみてください。
下記の図では3行目をクリックした場合ですが、ブレークポイントが設定されると赤枠で表示されます。
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1140820/image.jpeg)
【参考ドキュメント】ブレークポイントを設定する
そして再度スクリプトを実行してみて、ブレークポイントで一時停止した状態でコマンドウィンドウで
t_TRGe_V(t)+analwin_eeg_V(1):t_TRGe_V(t)+analwin_eeg_V(2)
を実行してみてください。
ここが正の整数になっていれば問題ないので、「再開」をクリックして次のfor文の繰り返しを実行します。
どこかのtの値で、t_TRGe_V(t)+analwin_eeg_V(1):t_TRGe_V(t)+analwin_eeg_V(2)がマイナスの値とか小数になっている可能性があります。
そしたらコマンドウィンドウで
t_TRGe_V(t)
や
analwin_eeg_V(1)
とか
analwin_eeg_V(2)
を実行して原因を特定できます。
More Answers (1)
Hernia Baby
on 30 Sep 2022
t_TRGe_V(t)+analwin_eeg_V(1):t_TRGe_V(t)+analwin_eeg_V(2)
上記が正の整数でないことが問題です。
Fp1_V の 0.001番目 と言われてエラーが起きてる感じです。
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!