Advertisement
Guest User

Untitled

a guest
Apr 17th, 2014
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. a='0.424870551E+03-0.100113019E+03 0.470220758E+03';
  2.  
  3. b=str2num(a);
  4.  
  5. b =324.7575 470.2208;
  6.  
  7. >> sscanf(a,'%E')
  8. ans =
  9. 424.8706
  10. -100.1130
  11. 470.2208
  12.  
  13. a = '0.424870551E+03-0.100113019E+03 0.470220758E+03';
  14. ind = a=='-'; %// detect positions of "-" ...
  15. ind2 = [0 a(1:end-1)=='E'];
  16. ind = ind & ~ind2; %// ... but not in exponents. Thanks to Rafael Monteiro
  17. asep = repmat(' ',1,numel(a)+nnz(ind)); %// initiallize with spaces
  18. asep((1:numel(a))+cumsum(ind)) = a; %// fill in a. Leave a blank before each "-"
  19. b = str2num(asep);
  20.  
  21. a =
  22. 0.424870551E+03-0.100113019E+03 0.470220758E+03
  23.  
  24. asep =
  25. 0.424870551E+03 -0.100113019E+03 0.470220758E+03
  26.  
  27. b =
  28. 424.8706 -100.1130 470.2208
  29.  
  30. str2num('0.424870551E+03-0.100113019E+03 0.470220758E+03')
  31. str2num('0.424870551E+03 - 0.100113019E+03 0.470220758E+03')
  32. str2num('0.424870551E+03- 0.100113019E+03 0.470220758E+03')
  33.  
  34. str2num('0.424870551E+03 -0.100113019E+03 0.470220758E+03')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement