X =
1.0000 1.2000 1.4000 1.6000 1.8000 2.0000
1.0000 1.2000 1.4000 1.6000 1.8000 2.0000
1.0000 1.2000 1.4000 1.6000 1.8000 2.0000
1.0000 1.2000 1.4000 1.6000 1.8000 2.0000
1.0000 1.2000 1.4000 1.6000 1.8000 2.0000
1.0000 1.2000 1.4000 1.6000 1.8000 2.0000
and Y=
1.0000 1.0000 1.0000 1.0000 1.0000 1.0000
1.2000 1.2000 1.2000 1.2000 1.2000 1.2000
1.4000 1.4000 1.4000 1.4000 1.4000 1.4000
1.6000 1.6000 1.6000 1.6000 1.6000 1.6000
1.8000 1.8000 1.8000 1.8000 1.8000 1.8000
2.0000 2.0000 2.0000 2.0000 2.0000 2.0000
and i need an n*2 matrix by pairing up corresponding elements of each of the matrices x and y. the
ex [ 1 1; 1.2 1; 1.4 1; 1.6 1; 1.8 1; 2 1; 1 1.2; 1.2 1.2;...............] and so on

 채택된 답변

Stephan
Stephan 2018년 11월 6일

0 개 추천

x = [1 2; 3 4]
y = [5 6; 7 8]
z = [x(:) y(:)]

댓글 수: 3

Bhavana Chinnabalannagari
Bhavana Chinnabalannagari 2018년 11월 6일
For bigger matrices, it gives away only the diagonal elements
Stephan
Stephan 2018년 11월 6일
편집: Stephan 2018년 11월 6일
No, see this example:
x = reshape(1:25,5,5)
y = reshape(26:50,5,5)
z = [x(:) y(:)]
result:
x =
1 6 11 16 21
2 7 12 17 22
3 8 13 18 23
4 9 14 19 24
5 10 15 20 25
y =
26 31 36 41 46
27 32 37 42 47
28 33 38 43 48
29 34 39 44 49
30 35 40 45 50
z =
1 26
2 27
3 28
4 29
5 30
6 31
7 32
8 33
9 34
10 35
11 36
12 37
13 38
14 39
15 40
16 41
17 42
18 43
19 44
20 45
21 46
22 47
23 48
24 49
25 50
Diagonal values would be 5 pairs - this are 25 pairs of values. I think this is what you expected - isnt it?
Bhavana Chinnabalannagari
Bhavana Chinnabalannagari 2018년 11월 6일
yeah , your right.

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

추가 답변 (0개)

카테고리

도움말 센터File 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