hold precision number textscan
    3 Ansichten (letzte 30 Tage)
  
       Ältere Kommentare anzeigen
    
Hellow, i'm using textscan to extract info out of an ascii file. My ascii file has a precision of six numbers after the point. But when i use my program, the numbers convert to a four digit number. my code is:
while (~feof(fid)) % For each block...
      InputText=textscan(fid,'%s',1,'delimiter','\n'); % Read header line
      HeaderLines{Block,1}=InputText{1};
      disp(HeaderLines{Block});
      NumCols= nd;
      FormatString=repmat('%f',1,NumCols);  % Create format string based on parameter
      InputText=textscan(fid,FormatString,'delimiter','slice'); % Read data block
      Data{Block,1}=cell2mat(InputText); % Convert to numerical array from cell
      [NumRows,NumCols]=size(Data{Block});  % Size of table
      disp(cellstr([xlate('Table data size: ') num2str(NumRows) ' x ' num2str(NumCols)]));
      disp(' '); % New line
      Block = Block+1;                            % Increment block index
  end
now when i use InputText=textscan(fid,'%f','delimiter','slice'); the resolution of my matrix isnt right anymore... Thx
0 Kommentare
Akzeptierte Antwort
  Walter Roberson
      
      
 am 29 Apr. 2011
        The program does not convert to four digits accuracy: you have set Matlab to only display 4 digits by default.
Give the command
format g long
and then display the matrix.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
				Mehr zu Text Files finden Sie in Help Center und File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

