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 (최근 30일)
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.

채택된 답변

Walter Roberson
Walter Roberson 2021년 8월 16일
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.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Whos에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by