Borrar filtros
Borrar filtros

How can I convert 2-D array to 1-D array.

4 visualizaciones (últimos 30 días)
Bhavnish
Bhavnish el 18 de Sept. de 2012
I am using a variable oprtn_pts. whose size is 3 2.
I want to convert this into 6*1. How can I do this?

Respuesta aceptada

Andrei Bobrov
Andrei Bobrov el 18 de Sept. de 2012
one way
out = oprtn_pts(:);
or
out = oprtn_pts.';
out = out(:);
other:
out = reshape(oprtn_pts,[],1);
or
out = reshape(oprtn_pts.',[],1);

Más respuestas (1)

Wayne King
Wayne King el 18 de Sept. de 2012
Editada: Wayne King el 18 de Sept. de 2012
oprtn_pts = randn(3,2);
oprtn_pts = reshape(a,6,1);
It takes the elements from oprtn_pts columnwise.
  3 comentarios
Andrei Bobrov
Andrei Bobrov el 18 de Sept. de 2012
Hi Bhavnish! Please see my answer.
Bhavnish
Bhavnish el 18 de Sept. de 2012
Hi Andrei, Thanks a lot for the help. I din't refresh my page earlier, so wasn't able to see your response. Yeah, your response is working absolutely fine for me... :-)

Iniciar sesión para comentar.

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!

Translated by