MATLAB Answers

ha ha
0

change last element in array by specific value matlab

Asked by ha ha
on 8 Jun 2019
Latest activity Commented on by ha ha
on 8 Jun 2019
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];

  0 Comments

Sign in to comment.

Tags

1 Answer

Answer by madhan ravi
on 8 Jun 2019
Edited by madhan ravi
on 8 Jun 2019
 Accepted Answer

Result = a;
if Result(end) == specific_value % specific value is 9 for example
Result(end) = 1;
end

  4 Comments

Show 1 older comment
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?

Sign in to comment.