Trying to make a 2 value sz vector, get Error using tabular/horzcat All input arguments must be tables.
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Alessandro Livi
el 6 de Jul. de 2024
Comentada: Alessandro Livi
el 10 de Jul. de 2024
Seems so simple, I'm trying to set a new table size based on values in a previous table
C = sum(app.UITable2.Data(1,:));
No matter how hard I try I can't get the sum of a single column!
So I give up and do
sz = [C(1,1) 4];
Get the weird error that all inputs must be tables!
Try making sz a known vector type
make a property
sz = [4 4]
then try
app.sz = [C(1,1) 4];
Sorry for all the asks but I'm a very experienced C, C++ (and many other languages) programmer but this .m code is driving me crazy! Help give all kinds of useless details about setting Fonts etc but little about simple syntax for e.g. summing a column.
S = sum(A,1); does sum by columns (vs ,2 for by rows but no way to say just do column 1. Even though C is a 1x4 Can't seem to get the scaler C(1,1) out of it properly.
C(1,1) or C(1) works in the command line, just not in my app created by app designer.
Ultimately all I really want is to make a new table of the correct size with
app.TrialsTable = table('Size',sz,'VariableTypes',{'uint8','uint8','categorical','int16'});
0 comentarios
Respuesta aceptada
Voss
el 6 de Jul. de 2024
T = table([1;2;3;4],{'ok';'let''s';'see';'here'})
Given the table T above, T(1,:) is another table containing the first row of T:
T(1,:) % returns a table
and T(:,1) is another table containing the first column of T:
T(:,1) % returns a table
In other words, subscripting a table using parentheses returns another table. To get the data out of a table, you can use curly brace subscripting. For example, to get the first column of table data:
T{:,1} % returns a numeric column vector, not a table
sum(T{:,1})
sz = [sum(T{:,1}) 4]
The "weird error that all inputs must be tables!" is due to trying to horizontally concatenate a table with a non-table, as in
[T(1,1) 4]
because T(1,1) is a table and 4 is not.
6 comentarios
Voss
el 7 de Jul. de 2024
Any of the following:
app.TrialsTable.Var3{ii+xx} = 'R';
app.TrialsTable.Var3(ii+xx) = {'R'};
app.TrialsTable{ii+xx, 3} = {'R'};
Más respuestas (0)
Ver también
Categorías
Más información sobre Categorical Arrays en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!