how assign cellarray to field Struct

1 次查看(过去 30 天)
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.

采纳的回答

Stephen23
Stephen23 2024-4-8
编辑:Stephen23 2024-4-8
"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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Structures 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by