필터 지우기
필터 지우기

Element-wise creation of Matrix

조회 수: 1 (최근 30일)
Navdeep Singh
Navdeep Singh 2016년 10월 28일
댓글: Walter Roberson 2016년 10월 28일
How can we create element wise matrix from 4 matrices without using loops. For ex.we have
A=[a1 a2;a3 a4] B=[b1 b2;b3 b4] C=[c1 c2;c3 c4] D=[d1 d2;d3 d4]
We need to create an array such that each array location contains values such as
R=[a1 b1;c1 d1] %Matrix on First location
S=[a2 b2;c2 d2] %Matrix on Second location
and so on so that all the elements are covered.
Thanks in advance.
  댓글 수: 1
Navdeep Singh
Navdeep Singh 2016년 10월 28일
I think about cell array but don't know how to use it.

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2016년 10월 28일
idx = 1;
R = [A(idx), B(idx); C(idx), D(idx)]
?
  댓글 수: 2
Navdeep Singh
Navdeep Singh 2016년 10월 28일
Yes you are correct but I have modified the question. Please check it.
Walter Roberson
Walter Roberson 2016년 10월 28일
cellfun(@(a, b, c, d) [a, b;c, d], A, B, C, D, 'uniform', 0)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by