I have made progress with my code... I now am able to write the lines the way I want to. How do I write the lines back into the file where they were before?
clear; clc; close all;
delta = 2.335;
lst = dir('*.txt'); % Collect list of .wsw files to convert
for n = 1:size(lst,1)
t = lst(1).name;
fid = fopen(t);
tline = fgets(fid);
count = 1;
while ischar(tline)
count = count + 1;
tline = fgetl(fid);
if tline(1) == 'S'& tline(2)== 'O'
disp(tline(15:21));
elev = str2num(tline(15:21));
elev = elev + delta;
elev = num2str(elev);
tline(15:21)= elev(1:7);
disp(tline);
% fprintf(tline,'%100s', fid(count,:));
else if tline(1) == 'R'& tline(2)== ' '
disp(tline(15:21));
elev = str2num(tline(15:21));
elev = elev + delta;
elev = num2str(elev);
tline(15:21)= elev(1:7);
disp(tline);
% fprintf(tline,'%100s', fid(count,:));
else if tline(1) == 'T'& tline(2)== 'S'
disp(tline(15:21));
elev = str2num(tline(15:21));
elev = elev + delta;
elev = num2str(elev);
tline(15:21)= elev(1:7);
disp(tline);
% fprintf(tline,'%100s', fid(count,:));
else if tline(1) == 'S'& tline(2)== 'H'
disp(tline(15:21));
elev = str2num(tline(15:21));
elev = elev + delta;
elev = num2str(elev);
tline(15:21)= elev(1:7);
disp(tline);
% fprintf(tline,'%100s', fid(count,:));
end
end
end
end
end
end