Borrar filtros
Borrar filtros

how assign cellarray to field Struct

2 visualizaciones (últimos 30 días)
Luca Re
Luca Re el 7 de Abr. de 2024
Comentada: Luca Re el 8 de Abr. de 2024
bb
ans =
27×1 cell array
{'On Micro'}
{'On Micro'}
{'On Micro'}
{'On Micro'}
{'On Micro'}
{'On Micro'}
i want this:
app.Sis(1).Trading=bb(1);
app.Sis(2).Trading=bb(2);
..
i try this:
K>> app.Sis.Trading=bb
Scalar structure required for this assignment.
K>> [app.Sis.Trading]=bb
Insufficient number of outputs from right hand side of equal sign to satisfy assignment.

Respuesta aceptada

Stephen23
Stephen23 el 8 de Abr. de 2024
Editada: Stephen23 el 8 de Abr. de 2024
"thank..but it's possible to avoid loop?"
Of course (depending on the sizes and classes of APP, SIS, etc):
app.Sis = struct('blah',cell(27,1));
bb = repmat({'On Micro'},27,1);
[app.Sis.Trading] = bb{:} % <----- no loop
app = struct with fields:
Sis: [27x1 struct]
Checking:
app.Sis
ans = 27x1 struct array with fields:
blah Trading

Más respuestas (0)

Categorías

Más información sobre Structures 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