From: Jeremy on
I have a minute problem going on. I'm wanting to make lists in .txt files, with headers and columns. I get the headers and i get the columns, but the numbers themselves are not doing what i want them to. Instead of putting one variable in one column, it runs the first variable across the first row, and continues on the second. When it stops, the next one does the same thing. Here is an example of my coding.

%% 1 dt=0.1
y(1)=0.5;
t(1)=0;
dt=0.1;
i=0;

while t<=1
i=i+1;
t(i+1)=t(i)+dt
y(i+1)=y(i)+dt.*(1 + 0.6.*(y(i).^2));
end

fid=fopen('HW61a.txt','w+');
fprintf(fid,'t y\n');
fprintf(fid,'%f %f\n',t,y);
fclose(fid);
type('HW61a.txt')

What's the problem here?