MATLAB Help-Sort with Carry
Problem: Write a function to sort one real array into ascending order while carrying along a second one. Test the function with the following two 9-element arrays:
This problem is asking that you sort array a into ascending order, while simultaneously carrying a along a second array b. In such a sort, each time an element of array a is exchanged with another element of array a, the corresponding elements of array b are also swapped. When the sort is over, the elements of array a are in ascending order, while the elements of array b that were associated with particular elements of array a are still associated with them.
This is what I have so far:
nvals=input('Enter numbers of values to sort for array1: ')
string=['Enter value ' int2str(ii) ': '];
sorted = sort(array1);
fprintf('\nSorted data for array1:\n');
This asks the user to input an amount of number values and from those values it sorts the array into ascending order. I don't know any command that can bind the elements in each of these two arrays and rearrange array b according to the rearranged array a.
If someone could please help, I would be very grateful.