Effacer les filtres
Effacer les filtres

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

1 vue (au cours des 30 derniers jours)
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!

Réponse acceptée

dpb
dpb le 1 Nov 2014
Modifié(e) : dpb le 2 Nov 2014
...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);

Plus de réponses (0)

Catégories

En savoir plus sur Graph and Network Algorithms dans Help Center et File Exchange

Tags

Aucun tag saisi pour le moment.

Community Treasure Hunt

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

Start Hunting!

Translated by