I want the data above the specified threshold to be colored in the table (in app designer)
18 ビュー (過去 30 日間)
古いコメントを表示
d=table2array(app.data);
d=rmmissing(d);
[Coeff,P]=corrcoef(d);
app.UITable5.ColumnName=app.VarNames;
app.UITable5.Data=Coeff;
app.UITable5.RowName=app.VarNames;
app.UITable6.ColumnName=app.VarNames;
app.UITable6.Data=P;
app.UITable6.RowName=app.VarNames;
nr=size(app.UITable5.Data,1);
nc=size(app.UITable5.Data,2);
t=app.TCorrelationEditField.Value;
for i=1:nr
for j=1:nc
if app.UITable5.Data(i,j)>=t
app.UITable5.BackgroundColor(i,j)=[1 0 0];
end
end
end
1 件のコメント
Ankit
2022 年 9 月 2 日
編集済み: Ankit
2022 年 9 月 2 日
which MATLAB version you are using?
app.OutputTable.BackgroundColor; % this will return the uitable background color
Add style to table or tree UI component - MATLAB addStyle - MathWorks Deutschland - if you are using version 2019a (here you can find some example too
回答 (1 件)
Rahul
2025 年 4 月 14 日
The functionality regarding adding a background colour to those cells of 'uitable' in App Designer which are above a certain threshold can be achieved in the following way:
- Creating a 'uistyle' object to target the 'BackgroundColor'.
- Iterating through a loop to check if the cell data is within the desired threshold or not.
- If condition is satisfied the using 'addStyle' function to apply the 'uistyle' to the particular cell in the table.
Here is an example:
threshold = 50;
% Create a style object
style = uistyle('BackgroundColor', 'red');
% Loop through the data and apply coloring
for row = 1:numRows
for col = 1:numCols
cellValue = data{row, col};
if isnumeric(cellValue) && cellValue >= threshold
addStyle(app.UITable, style, 'cell', [row, col]);
end
end
end
The following MathWorks documentations can be referred to know more:
Thanks.
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!