Вы можете использовать strrep
вместо символа SUB
. strrep
довольно эффективен и должен работать быстро даже с большими файлами.
Десятичное значение символа SUB
в ASCII равно 26.
Вот пример кода, который удаляет символ SUB
из входного файла input.txt
:
% Open files:
inputID = fopen('input.txt','r');
outputID = fopen('output.txt','w');
file_data=fread(inputID,'*char')'; % Read all data from input file
file_data_fixed = strrep(file_data,char(26),''); % Find and replace the SUB char with blank
fprintf(outputID,'%s',file_data_fixed); % Print all data (without SUB) to output file
% Close files:
fclose(inputID);
fclose(outputID);