UItable(app.UITable2) filters it's with respect to Name (app.Filter_Name). But the table does not update display data of the table.
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
shnrndll
le 16 Août 2021
Commenté : shnrndll
le 17 Août 2021
app.Filter_Name = app.NAMEEditField.Value;
numRows = size(app.UITable2.Data,1);
r = 1;
for i = 1:numRows
if strcmp(app.UITable2.Data{i,1}, app.Filter_Name) %app.UITable2.Data{i,1} ~= app.Filter_Name
app.RowstoTake(r,1) = i; %app.RowstoTake(1,r)= i;
r = r + 1;
end
end
app.UITable2.Data = app.UITable2.Data{app.RowstoTake, :};
The following error arises, "Unable to concatenate the table variables 'Name' and 'Number', because their types are cell and double." Please advise.
0 commentaires
Réponse acceptée
Walter Roberson
le 16 Août 2021
app.UITable2.Data = app.UITable2.Data{app.RowstoTake, :};
Remember that {} requests the content of a table, as if you had done [Data{:,1}, Data{:,2}, Data{:,3} etc] . But if the variables are not compatible datatypes then that would be a problem.
Now... suppose that the table variables just happened to be compatible datatypes. For example if you had a table that was a mix of string and numeric, then {:,:} indexing can convert everything to string, giving a string array, and that would be legal. So imagine that happened, that it happened to work out on the right side, maybe giving a string array.
Now look on the left side of the assignment. app.UITable.Data is to be assigned... that string array then? Is it to be turned into whatever datatype worked out as being acceptable to convert everything to?? Even though now it is a table datatype ?
I would suggest to you that you should instead be using
app.UITable2.Data = app.UITable2.Data(app.RowstoTake, :);
This would be a matter of selecting rows from the table, returning a table object, suitable for storing into a place that is currently a table object.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Logical dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!