Hello,
I have two matrices for example A = [1; 2; 3; 4; 5] and B = [A; B; C; D; E]. I would like to combine them in such a way that I get C = [1; A; 2; B; 3; C; 4; D; 5; E].
Can you please help me with this task? Thank you so much ?

 ์ฑ„ํƒ๋œ ๋‹ต๋ณ€

Stephan
Stephan 2019๋…„ 1์›” 4์ผ
ํŽธ์ง‘: Stephan 2019๋…„ 1์›” 4์ผ

2 ๊ฐœ ์ถ”์ฒœ

Hi,
try:
A = [-1; -3; -5; -7; -9]
B = [2; 4; 6; 8; 10]
result = reshape(([A B])',[],1)
gives:
A =
-1
-3
-5
-7
-9
B =
2
4
6
8
10
result =
-1
2
-3
4
-5
6
-7
8
-9
10
or with symbolic variables:
syms a b c d e
A = [1; 2; 3; 4; 5];
B = [a; b; c; d; e];
result = reshape(([A B].'),[],1)
results in:
A =
1
2
3
4
5
B =
a
b
c
d
e
result =
1
a
2
b
3
c
4
d
5
e
Best regards
Stephan

๋Œ“๊ธ€ ์ˆ˜: 1

Ann
Ann 2019๋…„ 1์›” 5์ผ
Thank you so much for this two examples of solving this problem! It works perfectly in my task :)
Kind regards
Ann

๋Œ“๊ธ€์„ ๋‹ฌ๋ ค๋ฉด ๋กœ๊ทธ์ธํ•˜์‹ญ์‹œ์˜ค.

์ถ”๊ฐ€ ๋‹ต๋ณ€ (0๊ฐœ)

์นดํ…Œ๊ณ ๋ฆฌ

๋„์›€๋ง ์„ผํ„ฐ ๋ฐ File Exchange์—์„œ Linear Algebra์— ๋Œ€ํ•ด ์ž์„ธํžˆ ์•Œ์•„๋ณด๊ธฐ

์ œํ’ˆ

ํƒœ๊ทธ

์งˆ๋ฌธ:

Ann
2019๋…„ 1์›” 4์ผ

๋Œ“๊ธ€:

Ann
2019๋…„ 1์›” 5์ผ

Community Treasure Hunt

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

Start Hunting!

Translated by