how assign cellarray to field Struct

2 vues (au cours des 30 derniers jours)
Luca Re
Luca Re le 7 Avr 2024
Commenté : Luca Re le 8 Avr 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.

Réponse acceptée

Stephen23
Stephen23 le 8 Avr 2024
Modifié(e) : Stephen23 le 8 Avr 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

Plus de réponses (0)

Catégories

En savoir plus sur Structures dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by