Filtering Table in app designer

7 次查看(过去 30 天)
Kyle Koutonen
Kyle Koutonen 2021-2-28
回答: Deepak 2024-8-29
I have a table in app designiner and I adding a feature to filter the data and delter it if it's over a selected value, but with the loop i made it only deletes one of the last value that is taken into the rowsdelt variable? am I just storing the rows wrong I bet its s simple fix I'm just stuck.
Filter=app.CutOffValueEditField.Value;
n=size(app.t,1);
k=1
if(app.LowPassButton.Value)
for i=1:n
if app.UITable3.Data(i,app.ColumnNumberbeingevalulatedEditField.Value)>=Filter
rowsdelt(1,k)=i
end
end
app.UITable3.Data(rowsdelt,:)=[];

回答(1 个)

Deepak
Deepak 2024-8-29
Hi @Kyle Koutonen, it is my understanding, that you have created a table in the app designer, and you want to filter the table and delete the rows that are over a selected value. However, the loop you have written deletes only the last row and not all the required rows.
Upon investigation of the code, the issue seems to be that "k" is not being incremented in the for loop. This results in only the last row index being stored in "rowsdelt". Also, the variable "rowsdelt" needs to be initialized properly before the for loop to store the values.
Here is the updated MATLAB code with changes:
Filter = app.CutOffValueEditField.Value;
n = size(app.t, 1);
k = 1;
rowsdelt = []; % Initialize rowsdelt as an empty array
if app.LowPassButton.Value
for i = 1:n
if app.UITable3.Data(i, app.ColumnNumberbeingevalulatedEditField.Value) >= Filter
rowsdelt(1, k) = i; % Store the index of the row to delete
k = k + 1; % Increment k to store the next row index
end
end
app.UITable3.Data(rowsdelt, :) = [];
end
I hope this resolves the issue.

类别

Help CenterFile Exchange 中查找有关 Develop Apps Using App Designer 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by