Display number with engineering notation
    72 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
    Jared
      
 il 8 Nov 2011
  
    
    
    
    
    Modificato: Harry Dymond
      
 il 31 Mag 2020
            I'm trying to display a number I read in with textscan in engineering notation. I was trying to switch the format to short eng and do:
evalc('disp(x)')
But it doesn't matter what format I set, the format textscan reads it in is what it uses.
1 Commento
  Harry Dymond
      
 il 31 Mag 2020
				
      Modificato: Harry Dymond
      
 il 31 Mag 2020
  
			For the benifit of those stumbling across this old thread in search of answers: please see my answer below
Risposta accettata
  Walter Roberson
      
      
 il 8 Nov 2011
        My tests disagree with Jared's findings:
>> result = textscan('133423.3e7','%f')
result = 
    [1334233000000]
>> format short eng
>> evalc('disp(result{1})')
ans =
     1.3342e+012
>> result{1}
ans =
     1.3342e+012
Engineering format was indeed used for the output, and the output is not the same as the format of the value that was read in nor of the format the data was stored in
2 Commenti
  Walter Roberson
      
      
 il 9 Nov 2011
				Trying to set as input or as output? Are you using
textscan( get(handles.example,'String'), 'Some Format Here')
or are you using
set(handles.example, 'String', x) %where x is the numeric value
or are you using something like:
set(handles.example, 'String', evalc('format short eng; disp(x)'))
If you are trying to set the String parameter to a numeric value, then the conversion that MATLAB uses is not documented (as best I recall.)
Più risposte (2)
  Harry Dymond
      
 il 31 Mag 2020
        For the benifit of those stumbling across this old thread in search of answers: my FEX submission num2eng will do this, and offers SI prefixes as well as engineering notation.
0 Commenti
  owr
      
 il 8 Nov 2011
        Try sprintf with a format string. It converts the number to a text string with a format of your choosing. Some built in MATLAB functions use this trick, for example, edit the code for dlmread.
Vedere anche
Categorie
				Scopri di più su Entering Commands 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!



