Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Basic question on lists

Subject: Basic question on lists

From: Jeremy

Date: 12 Apr, 2010 15:38:04

Message: 1 of 2

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?

Subject: Basic question on lists

From: Jeremy

Date: 12 Apr, 2010 15:43:04

Message: 2 of 2

Sorry about the double post, i accidentally clicked back and resent the webpage info.

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us