Clear Filters
Clear Filters

how assign cellarray to field Struct

2 views (last 30 days)
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.

Accepted Answer

Stephen23
Stephen23 on 8 Apr 2024
Edited: Stephen23 on 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

More Answers (0)

Categories

Find more on Structures in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!