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!