Borrar filtros
Borrar filtros

matlab uitable parameters to be used

3 visualizaciones (últimos 30 días)
PA el 21 de Oct. de 2022
Comentada: Walter Roberson el 21 de Oct. de 2022
How can i take the ui tables name if it is not define in the variables class for the app?

Respuestas (2)

Walter Roberson
Walter Roberson el 21 de Oct. de 2022
In that situation, the ui table does not have any name. Depending on what properties were assigned to it, it might possibly have a useful Tag or UserData that can be used to distinguish it from other uitables.
MATLAB is full of anonymous objects. For example consider
A = 1 + 2 + 4
During execution of this, first plus(1,2) is executed, and the resulting object (1 x 1 double precision non-complex array, value 3) is not named before being passed in to plus() with 4. The result of the addition (1 x 1 double precision non-complex array, value 7) is temporarily not named, but then the assignment is executed to write the result into the variable named A .
Consider further
A(-1) = fprintf('%d\n', 1 + 2 + 4)
then the temporary result of 1 + 2 is not named, and the temporary result of adding 4 to that is not named, and then the fprintf() function is called resulting in 7 being displayed, and then fprintf returns the number of characters printed (2), and then the assignment is attempted and fails. This tells us that the entire right hand side is evaluated before the left is checked. And that further means that if you have something of the form
A(1) = f(1 + 2 + 4)
that the expression f(1 + 2 + 4) is not considered to be named immediately when f(1 + 2 + 4) executes: the result lives in a temporary unnamed object until MATLAB then looks to figure out whether A(1) is a valid destination for it. Which might not be the case, since A might be an incompatible data-type, or the result of the call to f() might be the wrong size to store into the scalar location A(1).
Likewise, if you do
B = {uitable(), uitable}
then the uitables that are created are not named as they are created, they live in temporary unnamed objects, and a temporary unnamed cell array is created from those temporary unnamed objects, and only then is the cell array given a name. The uitable inside the cell are not considered to be named. The first one is not considered to have the name B{1} for example: it just does not have a name.

PA el 21 de Oct. de 2022
Editada: Walter Roberson el 21 de Oct. de 2022
app.Xn_Pattern = uitable(app.GridLayout3_2);
app.Xn_Pattern.ColumnName = {'Description'; 'Name'; 'Unit'; 'Xn 1'};
app.Xn_Pattern.RowName = {};
app.Xn_Pattern.ColumnEditable = [false false false true];
app.Xn_Pattern.CellSelectionCallback = @Xn_PatternCellSelection;
%%%%%UI table
description = {'H1xn'; 'H2xn'; 'Bxn'; ...
'Txn'; 'Mxn' )};
units= {'mm'; 'mm'; 'mm'; 'mm'; 'mm'};
names = {'Hn'; 'Zn'; 'Wn'; 'Dn'; 'Pn' };
value1 = {0;0;0;0;0} ;
app.Xn_Pattern.Data = [description, names, units, value1];
i like to use the values of Pn and Wn in this calculation but cannot do it because they are not assigned to variables
Y1 = app.Pn.Value-app.Wn.Value/2;
Y2 = app.Pn.Value+app.Wn.Value/2;
i get an error from matlab which says:
Unrecognized method, property, or field 'Pn' for class 'GUI_APP'
  3 comentarios
PA el 21 de Oct. de 2022
Hi walter. Thanks for the responce , but i get error:Dot indexing is not supported for variables of this type.
Walter Roberson
Walter Roberson el 21 de Oct. de 2022
Where is the error occuring?
description = {'H1xn'; 'H2xn'; 'Bxn'; ...
'Txn'; 'Mxn'};
units= {'mm'; 'mm'; 'mm'; 'mm'; 'mm'};
names = {'Hn'; 'Zn'; 'Wn'; 'Dn'; 'Pn' };
value1 = {0;0;0;0;0};
app.Xn_Pattern.Data = cell2table(value1.', ...
'VariableNames', names);
app.Xn_pattern.Data.Properties.VariableUnits = units;
app.Xn_Pattern.Data.Properties.VariableDescriptions = description;

Iniciar sesión para comentar.


Más información sobre App Building 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!

Translated by