Adding UITable row data which consists of numbers and strings
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentar
Robert
am 1 Nov. 2022
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;}
Akzeptierte Antwort
Cris LaPierre
am 1 Nov. 2022
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)"
})
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Develop Apps Using App Designer finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!