フィルターのクリア

Delete elements in a array

123 ビュー (過去 30 日間)
Mate 2u
Mate 2u 2012 年 4 月 21 日
Hi, I have a large array. I want to delete certain elements in the array. I want to delete the 390th element, and then after that every 391th element......
So need to delete 390, 781, 1182 etc..........

採用された回答

Wayne King
Wayne King 2012 年 4 月 21 日
So when you say "array", you mean a 1-D vector?
X = randn(49121,1);
indices = 390:391:length(X);
X(indices) = [];
length(X)
  1 件のコメント
Image Analyst
Image Analyst 2012 年 4 月 22 日
Or: X(390:391:end) = [];

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

その他の回答 (1 件)

Wayne King
Wayne King 2012 年 4 月 21 日
X = randn(100,100);
% not sure how far you want the vector to go
indices = 390:391:1e4;
X(indices) = [];
Then you'll need to reshape X into an array. Or you can just replace the elements with NaNs
X = randn(100,100);
% not sure how far you want the vector to go
X(indices) = NaN;
  2 件のコメント
Mate 2u
Mate 2u 2012 年 4 月 21 日
it is 49121 array, and does not seem to be working. So this 49121 array would minus 125 elements and would be just less than 4900 then
Image Analyst
Image Analyst 2012 年 4 月 22 日
Yes. 48996 to be precise, just like it does give you in the 1D version above.

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

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by