I want to write the same text to the screen and in to a file. So I have to double the code:
fprintf('this is some text with numbers: %d, %d', x,y);fprintf(fid, 'this is some text with numbers: %d, %d', x,y);
Alternatively I can introduce a text string to avoid double code:
str = sprintf('this is some text with numbers: %d, %d', x,y);fprintf(str); fprintf(fid, str);
But obviously it does not work to use fprintf to write to mutliple files simultaneously? Would be nice if possible.
fprintf([1 fid],'this is some text with numbers: %d, %d', x,y);
Best Answer