Combining string cell arrays to put in UITable
Mostrar comentarios más antiguos
Happy Thanksgiving!
I am trying to create a table that stores notifications from our system by concatenating three strings together into a 1X3 Cell array. While this works fine if I'm trying to replace data in a UITable, it doesn't work if I want to append data. Previously in my project I used the get() and set() method to grab append data into the table, as shown below(All data is of type 'double'):
Final = [joints(2), joints(3),joints(4),mag]; %The HR, Ambient, Skin temp and Resultant g force in one line for
ED = get(app.UITable, 'Data'); %collecting data currently in table
new = [ED; Final]; %concatenating new data in table with new sensor data
set(app.UITable, 'Data', new); %putting 'new' data back into table
I am trying to recreate this method using strings but I keep getting an error. Here is that code below:
z = sprintf('%s has suffered a large hit! Please screen for concussion',per);
d = msgbox(z);
t = datetime('now');
tim = datestr(t);
g = num2str(grat,2);
together = {z, tim, g} %creates 1X3 cell array
DED = get(app.UITable_3, 'Data') %gets '[]' of type double
ged= num2cell(DED) %Tried converting '[]' to cell type
new = {ged, together}%Would like to 2x3 cell array, instead gets 1x2 cell array
set(app.UITable_3,'Data', new) %put data back
Error:
Error using matlab.ui.control.Table/set
Error setting property 'Data' of class 'Table':
Values within a cell array must be numeric, logical, or char
Error in Player_View2/alert (line 91)
set(app.UITable_3,'Data', new)
Error in Player_View2/SwitchValueChanged (line 185)
alert(app, app.P1,mag)
Error using matlab.ui.control.internal.controller.ComponentController/executeUserCallback (line 378)
Error while evaluating Switch PrivateValueChangedFcn.
Thanks in advance
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Cell Arrays en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!