So far I have managed to fgetl to the lines I want to restore using this bit of code:
fid = fopen(filename);
m = 1;
for n = 1:X
line_1 = fgetl(fid);
m = m+1;
n = m;
end
line2= fgetl(fid);
So now that I have the two strings saved, I managed to concatenate them together using strcat
newline = strcat(line_1,line_2);
So all that´s left to do is delete the old lines and replace with the new one.. still trying to figure this out..
OR
since now I have a complete string of variable names, find a way to use this string as the headers without manipulating the files themselves.
delimiter = {';',','};
headernames = strsplit(newline,delimiter);