Filter löschen
Filter löschen

combine 2 matrices to 1 matrix?

10 Ansichten (letzte 30 Tage)
Nimasha Pilippange
Nimasha Pilippange am 19 Feb. 2022
I have 2 matrices as A=[ 1 2 3 4 5] and B= [ 6 7 8 9 10] , How can I combine them so I can get C=[1 6 2 7 3 8 4 9 5 10]. I need for a large matrix. But first I will start with a small matrix.
Can anyone help?

Akzeptierte Antwort

Torsten
Torsten am 19 Feb. 2022
Bearbeitet: Torsten am 19 Feb. 2022
N = numel(A);
C = zeros(2*N,1);
C(1:2:end-1) = A;
C(2:2:end) = B;
  1 Kommentar
Nimasha Pilippange
Nimasha Pilippange am 19 Feb. 2022
Bearbeitet: Nimasha Pilippange am 19 Feb. 2022
Thank you for the reply. It works fine.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Matrices and Arrays 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