MATLAB: How to find and replace strings in a text file

MATLABtext filetextscan

Hi,
I've written my table to a text file; however, I need this text file to be delimited by three spaces, which MATLAB doesn't allow using the 'writetable' function. Therefore, I must find and replace each instance of the ' ' string with the ' ' string in my text file. I also need to replace the first line of my text file with another string. How can I accomplish this?
I've tried to use textscan for this, but I keep getting the following error:
snip3Capture.JPG
For visual clarity, here is what I am trying to accomplish with my text file:
snip1Capture.JPG(original)
snip2Capture.JPG(goal)

Best Answer

Skip the writetable.
filename = 'goal.txt';
[fid, msg] = fopen(filename, 'wt');
if fid < 0
error('Failed to open output file "%s" because "%s"', filename, msg);
end
fprintf(fid, '"Time" "X" "Y" "Pressure"\n');
fprintf(fid, '%g %g %g %g\n', YourTable{:,:}.' ); %transpose is needed
fclose(fid);