Borrar filtros
Borrar filtros

How to send to an output file !

2 visualizaciones (últimos 30 días)
Fatima Al Marzoqi
Fatima Al Marzoqi el 27 de Jun. de 2014
Respondida: Image Analyst el 27 de Jun. de 2014
I create a code, and decide to send an output to a file, but not all the values displayed.
This is the code
x=-1:0.1:1;
a=1+(x.^2)+((x.^4)/2);
b=exp(x.^2);
c=abs(b-a);
y=[x a b c];
fid=fopen('Taylor.exp','w');
disp('X Approx.Values exp(x.^2) Absolute Error')
disp('________________________________________________________________________________________________')
fprintf(fid,'%.1f\t\t%.7f\t\t%.7\t\t%.7f\n',y);
fclose(fid);
please I want the answer as soon as possible!

Respuestas (1)

Image Analyst
Image Analyst el 27 de Jun. de 2014
You have a .7 instead of a .7f. I also opened it in write text mode. Try this:
clc;
x=-1:0.1:1;
a=1+(x.^2)+((x.^4)/2);
b=exp(x.^2);
c=abs(b-a);
y=[x a b c];
fid=fopen('Taylor.exp','wt');
fprintf(fid,'X Approx.Values exp(x.^2) Absolute Error\n');
fprintf(fid, '________________________________________________________________________________________________\n');
fprintf(fid, '\n%.1f\t\t%.7f\t\t%.7f\t\t%.7f\n', y);
fclose(fid);
type 'Taylor.exp'

Categorías

Más información sobre Power and Energy Systems en Help Center y File Exchange.

Etiquetas

Aún no se han introducido etiquetas.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by