Hello there,
I try to open a text file in a other folder, replace "," with "." and to close and save.
It works, but the new text is saved in the folder of my matlabscript. But I want, that it saved there, where it tooks the textfile to manipulate it, just overwrite the old one.
Maybe someone can help me. Thanks!
addpath('E:\Data\Test\X')testfiledir = 'E:\Data\Test\X';matfiles = dir(fullfile(testfiledir, '*.txt'));% A=dir ('*.txt')
B=matfiles(1).name;FileName=B;Data = fileread(FileName);Data = strrep(Data, ',', '.');FID = fopen(FileName, 'w');fwrite(FID, Data, 'char');fclose(FID);% type FileName; hier nicht benötigt
M= readmatrix(FileName);
Best Answer