How to joint together two matrix?

3 Ansichten (letzte 30 Tage)
Kenny
Kenny am 25 Feb. 2019
Beantwortet: madhan ravi am 25 Feb. 2019
I have these two matrix
A = 4 4 4 4 B = 1 2 3 4
3 3 3 3 1 2 3 4
2 2 2 2 1 2 3 4
1 1 1 1 1 2 3 4
I want to get together both, like this
C = 4,1 4,2 4,3 4,4
3,1 3,2 3,3 3,4
2,1 2,2 2,3 2,4
1,1 1,2 1,3 1,4
There is some function for this?

Antworten (2)

Kevin Phung
Kevin Phung am 25 Feb. 2019
A =[4 4 4 4 ;3 3 3 3;2 2 2 2;1 1 1 1];
B = repmat(1:4,4,1);
C = cell(1,numel(A));
for i = 1:numel(A)
C{i} = [A(i) B(i)];
end

madhan ravi
madhan ravi am 25 Feb. 2019
C=reshape(num2cell([A(:) B(:)],2),4,[]);
% celldisp(C)

Kategorien

Mehr zu Operators and Elementary Operations finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by