フィルターのクリア

Convert a vector into a structure array field

27 ビュー (過去 30 日間)
bbb_bbb
bbb_bbb 2017 年 10 月 20 日
コメント済み: bbb_bbb 2017 年 10 月 20 日
x= [2; 8; 6; 3; 7; 8];
for i=1:numel(x)
s(i).x=x(i);
end
Do the same, but without cycle.

採用された回答

Ray
Ray 2017 年 10 月 20 日
If struct s does not exist yet, you could use:
s = struct('x', num2cell(x));
  3 件のコメント
Walter Roberson
Walter Roberson 2017 年 10 月 20 日
if x is the same length as the number of entries in the struct array s, then
temp = num2cell(x);
[s.x] = temp{:};
bbb_bbb
bbb_bbb 2017 年 10 月 20 日
Thanks!

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

その他の回答 (0 件)

カテゴリ

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