フィルターのクリア

How can I combine two matrix ?

2 ビュー (過去 30 日間)
Fox
Fox 2016 年 1 月 8 日
コメント済み: Fox 2016 年 1 月 9 日
Hi I want to combine two matrix(matrix1= e1(743,7), matrix2= e2(743,7)), in the form of taking the first column of the first matrix and then the first from matrix2 then again the first from matrix1 and the second from matrix2 and so on. =>
e=[e1(:,1),e2(:,1),e1(:,1),e2(:,2)...,e1(:,1),e2(:,7),e1(:,2),e2(:,1)...,e1(:,2),e2(:,7),...,e1(:,7),e2(:,1)...e1(:,7),e2(:,7)]
Can somebody helps me how to create such a matrix e which is than a 743:49 matrix?
  2 件のコメント
jgg
jgg 2016 年 1 月 8 日
Is there a reason you don't want to use a loop to do this?
Fox
Fox 2016 年 1 月 8 日
No my problem is I'm not so sure how to program this. I mean the following isn't correct.
for i=1:7
for s=1:7
e(:,i+s)=[e(:,i),e(:,s)];
end
end
There I get the wrong solutions.

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

採用された回答

Roger Stafford
Roger Stafford 2016 年 1 月 8 日
e = reshape([reshape(repmat(e1,7,1),[],49);repmat(e2,1,7)],[],2*49);
  1 件のコメント
Fox
Fox 2016 年 1 月 9 日
Thank you.

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

その他の回答 (1 件)

James Tursa
James Tursa 2016 年 1 月 8 日
Another way:
[y x] = ndgrid((1:7)+7,(1:7));
z = [x(:)';y(:)'];
ee = [e1 e2];
e = ee(:,z(:));
  1 件のコメント
Fox
Fox 2016 年 1 月 9 日
Thanks.

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

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by