Filtering Table in app designer
2 ビュー (過去 30 日間)
古いコメントを表示
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,:)=[];
0 件のコメント
回答 (1 件)
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.
0 件のコメント
参考
カテゴリ
Help Center および File 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!