How to delete a row if the value of a certain cell in a table is less than the first cell? and then carry out the same condition for the cell after it again.
15 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Abdulwahab Qarooni
il 5 Dic 2022
Risposto: Dyuman Joshi
il 5 Dic 2022
So I have a 36078x2 table. I want to take the the first value in the first row, first column and compare it with all the other values in the second column. If any values are less than the value being compared with I want it to delete that entire row. Then I want it to go to the row below it and carry out the same function and so on until the last row.
I think this is right for comparing with the first row but I didn't understand how to make a function for it to go to the next row and compare with the rest:
i=data_A213(1,2)
data_A213(:,2)<i, :)
0 Commenti
Risposta accettata
Dyuman Joshi
il 5 Dic 2022
%random data for example
y=rand(10,2)
%index of rows that don't satisfy the constraint
idx=find(y(2:end,2)<=y(1,2))+1
%deletion
y(idx,:)=[]
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Matrix Indexing in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!