struct array

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

 采纳的回答

Andrei Bobrov
Andrei Bobrov 2011-9-22
[A(:).id] = B.id

6 个评论

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

请先登录,再进行评论。

更多回答(1 个)

类别

帮助中心File Exchange 中查找有关 Structures 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by