Build an array with different column lengths
16 ビュー (過去 30 日間)
古いコメントを表示
Have one large data set (3333x1 double) and am trying to section out rows based on certain index values. If I have say 10 index pairs (beginning and end row) that I want to section out,each with different lengths how can I build one new nx10 matrix?
I keep getting subscripted assignment mismatches and similar errors when I try things like:
for i = 1:length(indices)
newData(:,i) = olddata(indexstart(i):indexstop(i),:);
end
0 件のコメント
回答 (1 件)
Matt J
2016 年 8 月 15 日
編集済み: Matt J
2016 年 8 月 15 日
Usually you would store such a result as a cell array,
newData=cell(1, length(indices));
for i = 1:length(indices)
newData{i} = olddata(indexstart(i):indexstop(i));
end
If it needs to be a numeric array, you need to decide what will go in the missing spots.
4 件のコメント
参考
カテゴリ
Help Center および File Exchange で Matrices and Arrays についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!