convert vector a to b
    4 ビュー (過去 30 日間)
  
       古いコメントを表示
    
    nurhayat sahinkaya
 2018 年 12 月 26 日
  
    
    
    
    
    コメント済み: Image Analyst
      
      
 2018 年 12 月 27 日
            I have a vector, a:
a = [1 2 4 7 3 5 8 9 6 12 10 11 13 14] 
I want to create a vector, b, that writes the value of each element in this vector. The result for the vector I gave as an example is:
b = [1 2 5 3 6 9 4 7 8 11 12 10 13 14]
 So, a vector in the value of 3 is the 5th rank in the b vector 3 as in the order to write 5.
How do I convert a vector to b?
2 件のコメント
  Image Analyst
      
      
 2018 年 12 月 26 日
				I don't understand.  So starting with "a", the 3 is in the 5th element.  Since we don't yet have "b" (it's not been created from "a" yet), what do you mean by "3 is the 5th rank in the b vector".  What do you mean by "rank" of the vector?  The 3 is in element 4 of "b", and there is a 5 in element 3 of "b".  But I don't really know how each element of b is created.
  Image Analyst
      
      
 2018 年 12 月 27 日
				OK, I think David figured it out.  I guess rank really means the sort order rather than rank of a matrix. I never was able to understand "the value of 3 is the 5th rank in the b vector 3 as in the order to write 5" but I guess David luckily was.  Be sure to see David's clairvoyant answer below.
採用された回答
  David Goodmanson
      
      
 2018 年 12 月 27 日
        
      編集済み: David Goodmanson
      
      
 2018 年 12 月 27 日
  
      Hi nurhayat,
try
[~, b] = sort(a)
so that b is the set of indices of a such that a(1) = 1, a(2) = 2, a(5) = 3, a(3) = 4 etc. and generally a(b) = 1:14, sorted order.  
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
				Help Center および File Exchange で Logical についてさらに検索
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


