How can I remove apostrophe from a number?

4 次查看(过去 30 天)
I want to rad data from a text file. But I got a problem : MATLAB can't read a number with an apostrophe (158'289.641000 for example).
I want to convert it into that number : 158289.641000
This code works until the first number with apostrophe :
fid= fopen('test.txt', 'r');
rawdata= textscan(fid, '%s %s %s', 'headerlines', 44);
fclose(fid)
tmel = rawdata{1,1};
Imel = rawdata{1,3};
Tank you
  5 个评论
Arthur Savioz
Arthur Savioz 2020-2-29
For example 12'500
apostrophe is the ' caractere
darova
darova 2020-2-29
YOu can use notepad for removing apostrophe
Just press Ctrl+H

请先登录,再进行评论。

采纳的回答

Image Analyst
Image Analyst 2020-2-29
This works
fullFileName = fullfile(pwd, 'MATBIP_04_Channel_1.txt');
% Open the file for reading in text mode.
fileID = fopen(fullFileName, 'rt');
% Read the first line of the file, but don't use this header line.
textLine = fgetl(fileID);
% Read the second line of the file.
textLine = fgetl(fileID);
lineCount = 0;
while ischar(textLine)
lineCount = lineCount + 1;
% Print out what line we're operating on.
fprintf('%s\n', textLine);
% Get rid of quotes
textLine(textLine == '''') = [];
% Parse string into numbers.
numbers(lineCount, 1:3) = sscanf(textLine, '%f %f %f');
% Read the next line.
textLine = fgetl(fileID);
end
% All done reading all lines, so close the file.
fclose(fileID);

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Characters and Strings 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by