How to replace the 5 in my vector with decreasing numbers like 5,4,3,2,1

1 visualización (últimos 30 días)
x(3:4,3:5) = 5
  3 comentarios
Walter Roberson
Walter Roberson el 24 de Feb. de 2020
This is not clear, as you do not appear to have a vector.
Pallav Patel
Pallav Patel el 24 de Feb. de 2020
Try the command in Matlab and you will see the columns and rows specified will be filled with 5's. Matlab automatically fills an undefined vector with zeros. what I am trying to do is have a decreasing or increasing number and that was just a template to upload to Mathworks. I have seen such an example before but can't seem to find it.

Iniciar sesión para comentar.

Respuesta aceptada

Walter Roberson
Walter Roberson el 24 de Feb. de 2020
x(3:4,3:5) = reshape(5:-1:0, 2, 3);

Más respuestas (1)

madhan ravi
madhan ravi el 23 de Feb. de 2020
Z=num2cell(x);
Z(cellfun(@(zx)zx==5,Z))={5:-1:1}
celldisp(Z)

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by