Why do I lost negative values in cell
    3 ビュー (過去 30 日間)
  
       古いコメントを表示
    
    Jean-Marie Sainthillier
      
 2020 年 3 月 12 日
  
    
    
    
    
    コメント済み: Jean-Marie Sainthillier
      
 2020 年 3 月 12 日
            If S={'md' 0 1 2 3 -1} for example with 'md' for missing data and values between -3 and 3 (-3,-2,-1,0,1,2,3).
- double([S{2:end}]), I obtain [0 1 2 3 -1]. Everything is OK.
- double([S{1:end}]), I obtain [109 100 0 1 2 3 0]. 109 and 100 for ascii codes of 'md', OK but I lost my negative value -1 (0 instead).
I understand that I mix two types of data (char and signed integers) and that the array concatenation operator [] must choose, but why negative values are impacted ?
Thank you in advance.
0 件のコメント
採用された回答
  Ameer Hamza
      
      
 2020 年 3 月 12 日
        
      編集済み: Ameer Hamza
      
      
 2020 年 3 月 12 日
  
      When you run
[S{1:end}]
The MATLAB returns the value as a char array, which is similar to unit16 array. It can only hold values between 0 to 65535. If you input negative values, it is converted to zero, and any positive value above 65535 is converted to 65535. For example
>> double(char(100000))
ans =
       65535
>> double(char(-10))
ans =
     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!

