Info
Cette question est clôturée. Rouvrir pour modifier ou répondre.
Trying to use dlmread and getting a couple errors, pretty urgent
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Mismatch between file and format character vector.
Trouble reading 'Numeric' field from file (row number 47, field number 4) ==> + 0.64967 1.00000 1.54 1 1 1 1 1.54\n
I literally just installed a free trial and started using MATLAB. I'm trying to use some data I got from the Human Mortality Database (uploaded a text file). I attached the data to this thread. I'm trying to convert this data into a matrix.
Any ideas? Also, if anyone's willing to get in touch with me and guide me through this entire process of using MATLAB for my project, I'll even go as far as giving you a gift on PayPal.
0 commentaires
Réponses (1)
Image Analyst
le 22 Fév 2019
Modifié(e) : Image Analyst
le 22 Fév 2019
I think you're going to have to write a custom reader, because not all lines have the same number of numbers on them. Some lines have "110+ " instead of two numbers.
Use
% Open the file.
fileID = fopen(fullFileName, 'rt');
% Read the first line of the file.
textLine = fgetl(fileID);
while ischar(textLine)
% Print out what line we're operating on.
fprintf('%s\n', textLine);
% Read the next line.
textLine = fgetl(fileID);
% Now parse textLine and be sure to handle all special/unusual cases.
if contains(textLine, '110+')
% etc.
else
end
end
% All done reading all lines, so close the file.
fclose(fileID);
1 commentaire
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!