How can I change value of array?
2 ビュー (過去 30 日間)
古いコメントを表示
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 array
A = [1000,700,500,350,200,100,50,15];
for i = 1:a
B = A(i)
end
but B is not an array. How can I do?
4 件のコメント
Jan
2018 年 5 月 11 日
@sc: Please stop closing your question, when they got accepted answers already. After closing the questions are deleted, and this would remove the invested time of the ones, who help you. This is counter-productive in a public forum.
採用された回答
Jan
2018 年 5 月 7 日
Maybe:
B = numel(A):-1:1
if the array A is sorted already. Otehrwise:
[~, B] = sort(A, 'ascend')
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Multidimensional Arrays についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!