How to vectorize the following code

1 回表示 (過去 30 日間)
pietro
pietro 2014 年 10 月 3 日
コメント済み: pietro 2014 年 10 月 8 日
Hi all,
I have the following code, is there any way to vectorize it?
RMH(1).D=rand(20,4);
RMH(2).D=rand(20,4);
a=zeros(length(RMH),numel(RMH(1).D));
for i=1:length(RMH)
a(i,:)=reshape(RMH(i).D,1,numel(RMH(i).D));
end
Thank you
Regards
Pietro
  2 件のコメント
Matt J
Matt J 2014 年 10 月 3 日
Your code doesn't run, so of course there's no way to vectorize it.
pietro
pietro 2014 年 10 月 3 日
you're on right. I have just fixed.

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

採用された回答

Andrei Bobrov
Andrei Bobrov 2014 年 10 月 3 日
編集済み: Andrei Bobrov 2014 年 10 月 3 日
a = reshape([RMH.D],[],numel(RMD))';
  1 件のコメント
pietro
pietro 2014 年 10 月 8 日
Thanks

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by