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

 Respuesta aceptada

Stephan
Stephan el 6 de Nov. de 2018

0 votos

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

3 comentarios

Bhavana Chinnabalannagari
Bhavana Chinnabalannagari el 6 de Nov. de 2018
For bigger matrices, it gives away only the diagonal elements
Stephan
Stephan el 6 de Nov. de 2018
Editada: Stephan el 6 de Nov. de 2018
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 el 6 de Nov. de 2018
yeah , your right.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Community Treasure Hunt

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

Start Hunting!

Translated by