Delete elements in a array
191 次查看(过去 30 天)
显示 更早的评论
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..........
0 个评论
采纳的回答
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 个)
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 个评论
Image Analyst
2012-4-22
Yes. 48996 to be precise, just like it does give you in the 1D version above.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Type Conversion 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!