struct array

9 visualizzazioni (ultimi 30 giorni)
zhang
zhang il 22 Set 2011
Hi guys,
There are two struct arrays, A, B; They both have a member data called "id". For example: A(1).id = []; A(2).id = [] B(1).id = 'hello'; B(2).id = 'yes';
I'd like to copy the "id" of B to A without using loop.
Is there any method?
Thanks
  1 Commento
Fangjun Jiang
Fangjun Jiang il 22 Set 2011
help deal, among a few other solutions.

Accedi per commentare.

Risposta accettata

Andrei Bobrov
Andrei Bobrov il 22 Set 2011
[A(:).id] = B.id
  6 Commenti
Andrei Bobrov
Andrei Bobrov il 22 Set 2011
Sorry, this is my english. I mean, you must answer the question and the author takes his
Fangjun Jiang
Fangjun Jiang il 22 Set 2011
Both you and Daniel provided the same good solution. I just want to point it out that (:) can be omitted. The OP didn't seem to accept many of the obviously correct answers.

Accedi per commentare.

Più risposte (1)

Daniel Shub
Daniel Shub il 22 Set 2011
Does this work?
[A(:).id] = B(:).id

Categorie

Scopri di più su Structures in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by