delete the first n elements of each cell

1 ビュー (過去 30 日間)
Chaoyang Jiang
Chaoyang Jiang 2018 年 5 月 3 日
コメント済み: Chaoyang Jiang 2018 年 5 月 3 日
Given cell a, how to delete the first n elements of each cell? I am now using for loop. However, when the loop is big (5021889 loops), this line can be very slow.
May I know if there is a faster version or vectorized version of this?
Thank you
a=cell(2,1);
a{1,1}=1:10;
a{2,1}=1:10;
b=[3,8];
for i=1:2
a{i,1}(1:b(i))=[];
end

採用された回答

Stephen23
Stephen23 2018 年 5 月 3 日
I doubt that there is a much faster way, because what you are doing resizes the arrays themselves. cellfun will likely be slower.
  2 件のコメント
Chaoyang Jiang
Chaoyang Jiang 2018 年 5 月 3 日
Thank you for your answer.

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

その他の回答 (0 件)

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by