Create n arrays given a specified n with similar names

10 ビュー (過去 30 日間)
Joseph
Joseph 2014 年 10 月 2 日
コメント済み: Joseph 2014 年 10 月 2 日
% split into dfferent event arrays
no_events = length(event_id);
for i = 1:no_events; % no_events can be anything from 1 to 100, and I don't want to write 100 if/elseif statements
if i == 1
Event1 = [];
elseif i == 2
Event2 = [];
elseif i == 3
Event3 = [];
else
end
end
How can I write this more concisely?

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2014 年 10 月 2 日
編集済み: Azzi Abdelmalek 2014 年 10 月 2 日
no_events=10
for i = 1:no_events;
v.(sprintf('event%d',i))=[]
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB Coder についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by