Combining a matrix with a null matrix

2 visualizaciones (últimos 30 días)
Arjun Upadhyay
Arjun Upadhyay el 1 de Sept. de 2020
Comentada: Arjun Upadhyay el 3 de Sept. de 2020
I have a very basic problem. I want to replace some entries of zero matrix with the elements of another non zero matrix. I tried with for loop by using conditional statements. But it didn't work.
x = [1 2 3 4], Y= [0 0 0 0 0 0 0 0 0 0]
desired output
z = [1 2 3 4 0 0 0 0 0 0]
So anyone please help. Thanks in advanced

Respuesta aceptada

David Hill
David Hill el 1 de Sept. de 2020
z=Y;
z(1:length(x))=x;
  1 comentario
Arjun Upadhyay
Arjun Upadhyay el 3 de Sept. de 2020
I have done this with the the help of conditional statements and for loop. But this is quick and easy solution. Thank you.

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.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by