change last element in array by specific value matlab

Let's say I have matrix a
a=[1 2 3 4 5 6 7 8 9];
it's observed that the last value of array a is "9".
I want to change this value to be 1
Hope result is:
reslut=[1 2 3 4 5 6 7 8 1];

 Respuesta aceptada

madhan ravi
madhan ravi el 8 de Jun. de 2019
Editada: madhan ravi el 8 de Jun. de 2019
Result = a;
if Result(end) == specific_value % specific value is 9 for example
Result(end) = 1;
end

4 comentarios

Or perhaps all you need simply is:
Result = a;
Result(end) = 1;
ha ha
ha ha el 8 de Jun. de 2019
actually 9 is the last value of array "a". 9 is NOT specific value. that's why , for general, I don't know specific value. Can you fix the code?
ha ha
ha ha el 8 de Jun. de 2019
Thanks madhan ravi

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Etiquetas

Aún no se han introducido etiquetas.

Preguntada:

el 8 de Jun. de 2019

Comentada:

el 8 de Jun. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by