I wrote this function to write all numbers w(i) in a text document.
But as you can see the program only writes the last number w(12) = 2^12 in the document.
What can I do to get all w(i) into the document?
function testN = 12;k = 2;for i = 1:N-1w(i) = k^i;w(i) fid = fopen('Test2.txt', 'w'); fprintf(fid, '%s\n', 'Data w'); fprintf(fid, '%6.4f\t', w(i)); fclose(fid); end end
Best Answer