フィルターのクリア

copy matrix to struct array

3 ビュー (過去 30 日間)
DF
DF 2017 年 2 月 3 日
回答済み: Stephen23 2017 年 2 月 3 日
I have a struct array as following:
M(1).x = ones(5,5);
M(2).x = ones(5,5);
M(3).x = ones(5,5);
and a matrix
A = magic(5);
which I would like to copy to all 3 elements of the struct array (replacing the values in the 'x'-field) without using a for loop. How can I do that?
Thank you in advance!
  1 件のコメント
DF
DF 2017 年 2 月 3 日
I think I figured it out: it's function 'deal' I was looking for.

サインインしてコメントする。

回答 (1 件)

Stephen23
Stephen23 2017 年 2 月 3 日
[M.x] = deal(A)

カテゴリ

Help Center および File ExchangeStructures についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by