Saving textfiles in a other folder
Mostrar comentarios más antiguos
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);
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Characters and Strings en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!