converting array to single
    5 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
    OLUBUKOLA ogunsola
 il 14 Giu 2016
  
    
    
    
    
    Modificato: Walter Roberson
      
      
 il 15 Giu 2016
            i have this output:
output = dial ('1FUNDOG4YOU')
output =
       1     3     8     6     3     6     4     4     9     6     8
  (1 X 11) cell
but this is what i want
output :13863644968 
           (1X 1)
I've tried all sort of ridiculous stuff, str2num and the likes but nothing works . any idea on what to do to make the conversion happen? thanks
0 Commenti
Risposta accettata
  Stephen23
      
      
 il 14 Giu 2016
        
      Modificato: Stephen23
      
      
 il 14 Giu 2016
  
      If the elements of the cell array are numeric scalars:
>> C = {1,3,8,6,3,6,4,4,9,6,8};
>> sprintf('%d',C{:})
ans = 13863644968
Or if they are strings:
>> C = {'1','3','8','6','3','6','4','4','9','6','8'};
>> sprintf('%s',C{:})
ans = 13863644968
Note that this string has size 1x11 (strings are not size 1x1 in MATLAB). If you need it to be stored in a 1x1 array, then you can put it inside a cell.
3 Commenti
  Azzi Abdelmalek
      
      
 il 14 Giu 2016
				C = {1,3,8,6,3,6,4,4,9,6,8}
C=sprintf('%d',C{:})
C=uint64(str2num(C))
Più risposte (1)
  Walter Roberson
      
      
 il 14 Giu 2016
        Be careful, str2num() will create double precision with only 53 bits of precision. If you need the full 64 bits of precision you will need a different calculation.
C = {1,3,8,6,3,6,4,4,9,6,8};
Cv = uint64([C{:}]);
output = sum( Cv .* (uint64(10).^uint64(length(Cv)-1:-1:0)), 'native' );
6 Commenti
Vedere anche
Categorie
				Scopri di più su Data Type Identification in Help Center e File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



