필터 지우기
필터 지우기

How to send to an output file !

조회 수: 2 (최근 30일)
Fatima Al Marzoqi
Fatima Al Marzoqi 2014년 6월 27일
답변: Image Analyst 2014년 6월 27일
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!

답변 (1개)

Image Analyst
Image Analyst 2014년 6월 27일
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'

카테고리

Help CenterFile Exchange에서 Power and Energy Systems에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by