You are on page 1of 2

#include "gnuplot.

h"
using namespace std;
float q,ca,ch,hf,mf,mc,tf,tc;
float m1,m2,m3,t1,t2,t3;
///Examen 3
float fase_1(float T)
{
q=(ch*m1*(T-t1))-(hf*m2)+(ch*m2*(T-t2))+(m3*ca*(0-t3))-(hf*m3)+(ch*m3*(T-0)
);
return q;
}
float fase_2(float T)
{
q=(ch*m1*(0-t1))+(hf*m1)+(ca*m1*(T-0))+(ca*m2*(T-t2))+(ca*m3*(T-t3));
return q;
}
float fase_3(float M)
{
q=(ch*m1*(0-t1))+(ca*m3*(0-t3))-(hf*M);
return q;
}
float fase_4(float M)
{
q=(ch*m1*(0-t1))+(hf*M)+(ca*m3*(0-t3))+(ca*m2*(0-t2));
return q;
}
void E_3()
{
ch=0.5,hf=80,ca=1,m1=15,t1=-10,m2=10,t2=0,m3=10,t3=20;
float qr;
FILE * Arch;
Arch = fopen("datos.dat","w+");
/*for(float t=t1;t<t3;t+=0.01)
{
qr=fase_2(t);
fprintf(Arch,"%f %f \n",t,qr);
}
fclose(Arch);*/
for(float m=0;m<m1;m+=0.01)
{
qr=fase_4(m);
fprintf(Arch,"%f %f \n",m,qr);
}
fclose(Arch);
}
int main()
{
E_3();
Gnuplot plot;
plot("plot 'datos.dat' using 1:2") ;
system("pause");
return 0;

You might also like