Index of element to remove exceeds matrix dimensions??!
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Mariam Sheha
am 28 Mai 2016
Kommentiert: Mariam Sheha
am 28 Mai 2016
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 Kommentare
Akzeptierte Antwort
Matt J
am 28 Mai 2016
Bearbeitet: Matt J
am 28 Mai 2016
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)=[];
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!