I want to concatenate 1st row of a matrix A to all the rows of another matrix B,then the 2 nd row of matrix A to all the rows of matrix B and so on.Both the matrices are of different order.ex A=[1] and B=[2 3; 3 2],ans C=[1 2 3;1 3 2]. Is it possible in matlab to do this ?

댓글 수: 3

Jan
Jan 2016년 3월 21일
편집: Jan 2016년 3월 21일
The question contained confidential information about cracked software. I suggest the admins to delete it.
Image Analyst
Image Analyst 2016년 3월 22일
I'm not seeing it (now). Perhaps it's been "fixed".
Guillaume
Guillaume 2016년 3월 22일
편집: Guillaume 2016년 3월 22일
I can't remember what the title was exactly, I think it was just a bunch of numbers, but it didn't strike me as containing any confidential information nor mentioning any crack when I answered the question.

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

 채택된 답변

Guillaume
Guillaume 2016년 3월 21일

0 개 추천

%demo data
A = [1 2 3;4 5 6;7 8 9]
B = [2 3; 3 2]
%build all combinations of row indices of A and B:
[arows, brows] = ndgrid(1:size(A, 1), 1:size(B, 1));
%iterate over all combinations to build cell array of rows and convert cell array to matrix:
C = cell2mat(arrayfun(@(arow, brow) [A(arow, :), B(brow, :)], arows(:), brows(:), 'UniformOutput', false))

댓글 수: 1

komal rathod
komal rathod 2016년 3월 26일
It is working correctly.Thank you.

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

추가 답변 (0개)

카테고리

도움말 센터 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

질문:

2016년 3월 21일

댓글:

2016년 3월 26일

Community Treasure Hunt

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

Start Hunting!

Translated by