You can use my function fstrrep to replace each . with a , and then use dlmread to read the data:
fstrrep('test22.txt', ',', '.')
data = dlmread('test22.txt')
The m-file:
function fstrrep(filename, oldsubstr, newsubstr, newfilename)
fid1 = fopen(filename, 'r');
if fid1 == -1
error(['Cannot open file ' filename ' for reading.']);
end
if nargin < 4
newfilename = '_temp.txt';
end
fid2 = fopen(newfilename, 'w');
if fid2 == -1
error(['Cannot open file ' newfilename ' for writing.']);
end
line = fgets(fid1);
while line ~= -1
newline = strrep(line, oldsubstr, newsubstr);
fprintf(fid2, '%s', newline);
line = fgets(fid1);
end
st = fclose(fid1);
if st == -1
error(['Cannot close ' filename '.'])
end
st = fclose(fid2);
if st == -1
error(['Cannot close ' tempfilename '.'])
end
if nargin < 4
movefile(newfilename, filename)
end
Best Answer