필터 지우기
필터 지우기

write equation automatically and create a file which save the constant term of the equation

조회 수: 1 (최근 30일)
Hi all! I have a script for plot data. My script is:
for k=159:100:2048
ix=isfinite(LOGIR(:,k));
x=XMEAN(ix);
y=LOGIR(ix,k);
idx=[1:14]
p=polyfit(x(idx),y(idx),1);
yfit=polyval(p,x);
figure(k);
plot(x(idx),y(idx),'.',x,yfit,'r')
gtext(['y=',num2str(p(1)),'x+',num2str(p(2))])
xlabel('airmass')
ylabel('logirradiance')
print(sprintf('Figure(%d).bmp',k), '-dbmp')
end
I want the equation to appear automatically on the graph and not I place each one. Also, I want to create a file which will save the constant term of each equation. How can I do this?
Thank you!

채택된 답변

dpb
dpb 2014년 11월 1일
편집: dpb 2014년 11월 2일
...I want the equation to appear automatically on the graph and not I place each one.
Use text instead of gtext You'll have to use some pre-knowledge of what your curves look like to put it near the line where it doesn't interfere or pick a position known to be out of the way (like upper left or lower right).
xlab=some_x_position_in axes coordinates;
ylab=same_for_y;
text(x,y,num2str('y=%0.3f*x+%0.3f',p)
_ ...create a file which will save the constant term of each equation..._
Open the file before starting the loop and write each p(2) when it's been calculated.
fid=fopen('Yourdesiredfilename','wt');
for ...
...
fprintf(fid,'%f\n',p(2));
end
fid=fclose(fid);

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graph and Network Algorithms에 대해 자세히 알아보기

태그

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

Community Treasure Hunt

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

Start Hunting!

Translated by