Update on filtering table

4 visualizaciones (últimos 30 días)
Kyle Koutonen
Kyle Koutonen el 1 de Mzo. de 2021
Editada: Cris LaPierre el 1 de Mzo. de 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,:)=[];

Respuesta aceptada

Cris LaPierre
Cris LaPierre el 1 de Mzo. de 2021
Editada: Cris LaPierre el 1 de Mzo. de 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.

Más respuestas (0)

Categorías

Más información sobre Logical en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by