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 commentaire

Fangjun Jiang
Fangjun Jiang le 22 Sep 2011
help deal, among a few other solutions.

Connectez-vous pour commenter.

 Réponse acceptée

Andrei Bobrov
Andrei Bobrov le 22 Sep 2011

0 votes

[A(:).id] = B.id

6 commentaires

Fangjun Jiang
Fangjun Jiang le 22 Sep 2011
Golfer: [A.id]=B.id
Daniel Shub
Daniel Shub le 22 Sep 2011
I had 2 (:), andrei had 1, and Fangjun had none. I always forget about deal.
Andrei Bobrov
Andrei Bobrov le 22 Sep 2011
Hi Fangjun! It's your question! Answer!
Fangjun Jiang
Fangjun Jiang le 22 Sep 2011
@andrei, what do you mean? What is the question?
Andrei Bobrov
Andrei Bobrov le 22 Sep 2011
Sorry, this is my english. I mean, you must answer the question and the author takes his
Fangjun Jiang
Fangjun Jiang le 22 Sep 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.

Connectez-vous pour commenter.

Plus de réponses (1)

Daniel Shub
Daniel Shub le 22 Sep 2011

0 votes

Does this work?
[A(:).id] = B(:).id

Catégories

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by