How do I add two columns to a matrix in ascending order?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
I need a matrix which numbers ascend in the following way:
If I have the columns:
x=[1 2 3]
y=[4 5 6]
I want the matrix to be like:
A=[1 4
1 5
1 6
2 4
2 5
2 6
3 4
3 5
3 6]
I hope someone can help me with this.
0 comentarios
Respuesta aceptada
Azzi Abdelmalek
el 11 de Jun. de 2013
x=[1 2 3]
y=[4 5 6]
x1=repmat(x,numel(y),1)
out=[x1(:) repmat(y',numel(x),1)]
5 comentarios
Más respuestas (2)
Iain
el 11 de Jun. de 2013
x = repmat(x,numel(y),1)
y = repmat(y,1,size(x,2))
A = [x(:) y(:)]
0 comentarios
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!