function numReplaced=replaceMultiples(fname,num) clc num=0 fname='example.txt'; ifn=fname; ofn=['updated%d %s',num,fname]; ifh=fopen(ifn,'r'); % open the file for reading
ofh=fopen(ofn,'wt'); %open the output file for writing
ln=fgetl(ifh); % try to get the first line of the file
while str2num(fname) while ~isnan(num) [tk,ln]=strtok(ln); if mod(fname,num)==0 fprintf(ofh,'%s ',tk); %write to output file
end end fprintf(ofh,'\n'); %after the complete line has
ln=fgetl(ifh); end fclose(ifh); % close the file
fclose(ofh);
MATLAB: How to fix the function
functionhelpscript
Related Question
- How to change a specific part in a specific line in a text file
- Split binary number into individual bytes
- How to find the coefficients for an equation having the experimental data
- How to read n first lines of a txt file and keep the format when writing the read data to the new (another) text file
- Reorder a Cell arrays
Best Answer