フィルターのクリア

Simplifiing the MATLAB code

1 回表示 (過去 30 日間)
Rene Sebena
Rene Sebena 2016 年 11 月 4 日
コメント済み: Rene Sebena 2016 年 11 月 4 日
Hi there, I know this is something simple, but I am quite new in matlab and will aprreciate your help with this issue,
I know order of specific events in one dimension matrix:
e1 = [1,19,24]; % order of specific condition in matrix;
e2 = [2,8,27];
e3 = [4,16,23];
I have data with the same event type and I need to change event.type based on information above, so that:
EEG.event(1,1).type = 1;EEG.event(1,19).type = 1;EEG.event(1,24).type = 1;
EEG.event(1,2).type = 2;EEG.event(1,8).type = 2;EEG.event(1,27).type = 2;
EEG.event(1,4).type = 3;EEG.event(1,16).type = 3;EEG.event(1,23).type = 3;
How can I do it in simple way?
Thank you very much for your time and help!

採用された回答

Image Analyst
Image Analyst 2016 年 11 月 4 日
Would you like a for loop? This could be simpler if the e vectors were much long than 3 elements
for k = 1 : length(e1)
EEG.event(1,e1(k)).type = 1;
EEG.event(1,e2(k)).type = 2;
EEG.event(1,e3(k)).type = 3;
end
If e1, e2, and e3 don't all have the same length then you're best off using 3 separate for loops.
  1 件のコメント
Rene Sebena
Rene Sebena 2016 年 11 月 4 日
Thank you, this helped a lot!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by