Azzera filtri
Azzera filtri

How to send to an output file !

2 visualizzazioni (ultimi 30 giorni)
Fatima Al Marzoqi
Fatima Al Marzoqi il 27 Giu 2014
Risposto: Image Analyst il 27 Giu 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!

Risposte (1)

Image Analyst
Image Analyst il 27 Giu 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'

Categorie

Scopri di più su Power and Energy Systems in Help Center e File Exchange

Tag

Non è stata ancora inserito alcun tag.

Community Treasure Hunt

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

Start Hunting!

Translated by