Index of element to remove exceeds matrix dimensions??!
2 次查看(过去 30 天)
显示 更早的评论
Hello Everybody; i am having a problem with that code, regarding that i want to discards the columns with value less than 3...but it always gives me Index of element to remove exceeds matrix dimensions
can you please help me through that?!
[orderedCount, SortOrder]=sort(Count,'descend');
Items=Items(SortOrder);
%%%the propabilty of presence of each
for i=1:length(orderedCount)
if(orderedCount(i)<3)
items(i)=[];
end
end
0 个评论
采纳的回答
Matt J
2016-5-28
编辑:Matt J
2016-5-28
Looping will not work because the length and indexing of "Items" changes each time you remove an element. You must remove all of the elements simultaneously,
Items(orderedCount<3)=[];
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!