Filter löschen
Filter löschen

how assign cellarray to field Struct

2 Ansichten (letzte 30 Tage)
Luca Re
Luca Re am 7 Apr. 2024
Kommentiert: Luca Re am 8 Apr. 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.

Akzeptierte Antwort

Stephen23
Stephen23 am 8 Apr. 2024
Bearbeitet: Stephen23 am 8 Apr. 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

Weitere Antworten (0)

Kategorien

Mehr zu Structures finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by