Adding UITable row data which consists of numbers and strings
4 ビュー (過去 30 日間)
古いコメントを表示
As the title suggests, I am designing an app in App Designer, which has a table called app.UITable, and I am trying to add rows to the table as added below, then I recieve an error which is also added below. (please help)
Error:
Values within a cell array must be numeric, logical, or char"
Code:
% Code that executes after component creation
function startupFcn(app)
app.UITable.Data = {
0,0,0,"Consumption (kWh)";
0,0,0,"Consumption (RM)";
0,0,0,"ICPT (-RM0.02 per kWh)";
0,0,0,"ST";
0,0,0,"Current Month Consumption (RM)";
0,0,0,"Current Bill (RM)"
};
end
1 件のコメント
Robert
2022 年 11 月 1 日
Hi,this should do the job. Each line in the cell is a line in the table.
app.UITable.ColumnName = {"Consumption (kWh)";...
"Consumption (RM)";...
"ICPT (-RM0.02 per kWh)";...
"ST" ;...
"Current Month Consumption (RM)";...
"Current Bill (RM)";
}
app.UITable.Data = {1 2 3 4 5 6; 7 9 10 11 12 13;}
採用された回答
Cris LaPierre
2022 年 11 月 1 日
I'd suggest using cell2table to turn your cell array into a table.
app.UITable.Data = cell2table({0,0,0,"Consumption (kWh)";
0,0,0,"Consumption (RM)";
0,0,0,"ICPT (-RM0.02 per kWh)";
0,0,0,"ST";
0,0,0,"Current Month Consumption (RM)";
0,0,0,"Current Bill (RM)"
})
その他の回答 (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!