# MATLAB: How to change value of array

arraycyclefor

Hi!
I've an array that is A but I'd like to create another array, B, that containes in order the position of this values.
For example: if A is [1000,700,500,350,200,100,50,15], B must be [8,7,6,5,4,3,2,1].
I tried to do:
a = 8; % a is number of values in arrayA = [1000,700,500,350,200,100,50,15];for i = 1:aB = A(i)end
but B is not an array. How can I do?

#### Best Answer

Maybe:
B = numel(A):-1:1
if the array A is sorted already. Otehrwise:
[~, B] = sort(A, 'ascend')