Borrar filtros
Borrar filtros

Creating matrix from other matrix columns with loop?

1 visualización (últimos 30 días)
jack star
jack star el 23 de Abr. de 2016
Comentada: jack star el 23 de Abr. de 2016
Hi all. I have data matrixes x(15x16) and y(15x16). And I want to create new matrix z(15x16) by taking some columns of x and y. For example, 3-4-5-10-12-14-16th columns will be taken from x and others from y. Is it possible with loop?

Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 23 de Abr. de 2016
Editada: Azzi Abdelmalek el 23 de Abr. de 2016
You don't need a loop
out=y
idx=[3 4 5 10 12 14 16]
out(:,idx)=x
  3 comentarios
Azzi Abdelmalek
Azzi Abdelmalek el 23 de Abr. de 2016
Yes, there is a mistake in the last line
y=zeros(15,16);
x=randn(15,16);
out=y
idx=[3 4 5 10 12 14 16]
out(:,idx)=x(:,idx)

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements 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