Update on filtering table
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Kyle Koutonen
il 1 Mar 2021
Modificato: Cris LaPierre
il 1 Mar 2021
I posted a question on here the other day about filtering and it hasn't been answered yet, i made some changes to it but still have issue so I'm hoping if there are two posts one will be answered. So i made the loop to store which rows have values over the cut off value, the only problem is when row is under the cut off value a zero is put into the rows delt vector which screws up the deleteing of rows since the Table cannot have a zero input.
Filter=app.CutOffValueEditField.Value;
n=size(app.t,1);
if(app.LowPassButton.Value)
for i=1:n
if app.UITable3.Data(i,app.ColumnNumberbeingevalulatedEditField.Value)>=Filter
rowsdelt(i)=i
end
end
app.UITable3.Data(rowsdelt,:)=[];
0 Commenti
Risposta accettata
Cris LaPierre
il 1 Mar 2021
Modificato: Cris LaPierre
il 1 Mar 2021
Use logical indexing instead. You can do that without the for loop. (untested)
if ...
rowsdelt = app.UITable3.Data(:,app.ColumnNumberbeingevalulatedEditField.Value)>=Filter;
app.UITable3.Data(rowsdelt,:)=[];
end
Note that you'll want the delete command inside the if statement or you'll get an error about undefined variable rowsdelt anytime app.lowpassbutton.value is false.
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Logical 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!