cell2mat error in reading in e+ (scientific notation)

Hi
i'm really puzzled as this bit of code has worked well in the past - but now does not work properly, as it no longer converts the scientific notation of large numbers imported from the text file (i.e.5e+10), it gives numbers like 0.000001 instead, or just 0, when using cell2mat
fid=fopen('base.vtk','r'); % open the file; be sure to add the error-checking code
l=fgetl(fid); % read first record
while ~strcmp(l,'absorb_dens 1 1030301 double') % loop until find the magic record
l=fgetl(fid);
end
data=textscan(fid,'','collectoutput',1); % read, convert cell to double array
fid=fclose(fid); % done with file, go on..
data_1 = cell2mat(data);
does it work for you? my file is quite big but can be downloaded here.
it's a .vtk file - but when opend in matlab looks just like a .txt
thanks
Charlie

댓글 수: 3

textscan format of '' is undocumented .Historically it has been used internally by dlmread but should not be relied on .
cgenes
cgenes 2018년 12월 20일
bizarrely - in the console - these odd numbers are displayed - but actually in the variable the correct numbers are held
so my code above does actually work - the console representation of the data was confusing me
thanks
I would still heed Walter's warning that the syntax you're using is undocumented and likely to break under unspecified conditions (and not work at all in future versions of matlab).

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터File Exchange에서 Data Type Conversion에 대해 자세히 알아보기

질문:

2018년 12월 14일

댓글:

2018년 12월 20일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by