Error using dlmread (line 138)
Mismatch between file and format string.
Trouble reading 'Numeric' field from file (row number 1, field number 4) ==> ,055 -118,055 -117,055 -116,055
-115,055 -114,055 -113,055 -112,055 -111,055 -110,055 -109,055 -108,055 -107,055 -106,055
-105,055 -104,055 -103,055 -102,055 -101,055 -100,055 -99,055 -98,055 -97,055 ..
and also
Error in (line 52)
VeriImmaMis=dlmread(strcat(PathName,FileName),'\t',Range);
How can i fix this problem.

Réponses (1)

dpb
dpb le 4 Jan 2016
Modifié(e) : dpb le 4 Jan 2016

1 vote

The problem is the ',' in the fields; is it intended to be a decimal point or a thousands separator? Either way, you've got to handle it explicitly.
>> s='-115,055 -114,055'; % sample subline of type in file...
>> cell2mat(textscan(s,'%f,%f','collectoutput',1)) % read fields; return in array
ans =
-115 55
-114 55
>> ans(:,1)+ans(:,2)/1000
ans =
-114.9450
-113.9450
>>
If it's thousands separator, then
>> sign(ans(:,1)).*(abs(ans(:,1))*1000+ans(:,2))
ans =
-115055
-114055
>>
PS: Of course, you'll want to save the result of the textscan call on the file in a variable and use that when doing the conversion--this was just demo at command line to illustrate...
fid=fopen('yourfile');
v=cell2mat(textscan(fid,'%f,%f','collectoutput',1));
fid=fclose(fid);
%appropriate operation here on v by columns...

Catégories

En savoir plus sur Large Files and Big Data dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by