Coping cell array but skipping a specific column
古いコメントを表示
I have:
EMG =
1×3 cell array
{3×16 cell} {3×15 cell} {3×15 cell}
I need to copy the "first" 10 columns of each cell but for each iteration I need to skip column 1, for the second iteration column 2, for the third iteration column 3, and so on. The resulting cell array (3x30) needs to be:
Skipping first column
column1, column2, column3, column4, column5, column6… column28, column29, column30
column2ofcell1, column2ofcell2, column2ofcell3, column3ofcell1,column3ofcell2, column3ofcell3…column11ofcell1, column11ofcell2, column11ofcell3
Skipping second column
column1, column2, column3, column4, column5, column6… column28, column29, column30
column1ofcell1, column1ofcell2, column1ofcell3, column3ofcell1, column3ofcell2, column3ofcell3…column11ofcell1, column11ofcell2, column11ofcell3
where the column of each cell is copied.
I put the word first in quotations because the columns to be extracted are not contiguous, so it is not always 1:10, the fist iteration is 2:11 because I need to skip #1, on the second iteration I need to skip #2 so I need to copy, 1&3:11, for the third iteration I need to skip #3 and copy 1:2&4:11 and so on until I skip the first 10 columns.
Thank you,
採用された回答
その他の回答 (1 件)
Image Analyst
2018 年 7 月 4 日
Each of your cells in your cell array contains another cell array. We don't know what that cell array's cells contain but it doesn't matter. To extract/crop out the first 10 columns of the contained cell array, simply do
for k = 1 : length(ca)
thisCellsContents = ca{k}; % This is another cell array
% Take the first 10 columns of the cell array called "thisCellsContents"
ca{k} = thisCellsContents(:, 1:10);
end
Now I have no idea what you mean by iterations. Do you want to put that "crop first 10 columns" code into a for loop where you iterate it for some reason?
2 件のコメント
ErikaZ
2018 年 7 月 5 日
Image Analyst
2018 年 7 月 5 日
Why do you need to do this?
And please attach your varaible in a .mat file so we can do something with it.
カテゴリ
ヘルプ センター および File Exchange で Creating and Concatenating Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!