My problem is that when I use the script below, it works, but when I put it into loop, it crashes. Why is it so?
names = dir('C:\Users\User\Documents\OZEApp\tests\BufforTest*.txt');names = {names.name};fileName = names{4}; path = strcat('C:\Users\User\Documents\OZEApp\tests\', fileName); pathMatlab = strcat('C:\Users\User\Documents\OZEApp\testMatlab\', fileName); charPath = convertStringsToChars(path); charPathMatlab = convertStringsToChars(pathMatlab);Data = fileread(charPath);Data = strrep(Data, ',', '.');New = fopen(charPathMatlab, 'w');fwrite(New, Data, 'char');fclose(New);fid=fopen(charPathMatlab);
This one doesn't work:
names = dir('C:\Users\User\Documents\OZEApp\tests\BufforTest*.txt');names = {names.name};for fileName = names' path = strcat('C:\Users\User\Documents\OZEApp\tests\', fileName); pathMatlab = strcat('C:\Users\User\Documents\OZEApp\testMatlab\', fileName); charPath = convertStringsToChars(path); charPathMatlab = convertStringsToChars(pathMatlab);Data = fileread(charPath);Data = strrep(Data, ',', '.');New = fopen(charPathMatlab, 'w');fwrite(New, Data, 'char');fclose(New);fid=fopen(charPathMatlab);end
Best Answer