S
SS
I'd like, instead of outputting to a *.csv file to output the results from
the code below to an excel sheet.
I changed the datafile extension to read *.xls and it outputs the data but
does not put it into seperate cells
all i get is a coulmn of pairs of results seperated by a comma - i want two
columns of data
can anyone help...
========================================================================
# include <stdio.h>
main ()
{
FILE *datafile;
datafile = fopen ("a:\\lab1-1-1.csv","w");
float Dt = 0.01;
float u = 1;
float Tmax = 2;
float t = 0 , e = 0, y1 = 0, y = 0;
float J = 0.02;
float k = 10;
float B = 0.5;
while (t<=Tmax)
{
e = u - y ;
y1 = y1 +(k* Dt*e);
y = y+Dt/J*(k*y1-B*y);
printf("%7.3f %7.3f \n",t,y);
fprintf(datafile,"%7.3f, %7.3f \n ", t,y);
t = t+Dt;
}
fclose (datafile);
return 0
}
the code below to an excel sheet.
I changed the datafile extension to read *.xls and it outputs the data but
does not put it into seperate cells
all i get is a coulmn of pairs of results seperated by a comma - i want two
columns of data
can anyone help...
========================================================================
# include <stdio.h>
main ()
{
FILE *datafile;
datafile = fopen ("a:\\lab1-1-1.csv","w");
float Dt = 0.01;
float u = 1;
float Tmax = 2;
float t = 0 , e = 0, y1 = 0, y = 0;
float J = 0.02;
float k = 10;
float B = 0.5;
while (t<=Tmax)
{
e = u - y ;
y1 = y1 +(k* Dt*e);
y = y+Dt/J*(k*y1-B*y);
printf("%7.3f %7.3f \n",t,y);
fprintf(datafile,"%7.3f, %7.3f \n ", t,y);
t = t+Dt;
}
fclose (datafile);
return 0
}