34 lines
543 B
C
34 lines
543 B
C
#include <stdio.h>
|
|
#include <math.h>
|
|
|
|
#define N 100000
|
|
|
|
int main () {
|
|
|
|
float R = 10.0e3;
|
|
float C = 2000.0e-6;
|
|
float E=10.;
|
|
float tau = R*C ;
|
|
// printf("La constante de temps du circuit est %f sec.\n",tau);
|
|
|
|
float dt = 1.e-3;
|
|
float t;
|
|
|
|
/* for(t=0.;t<4.*tau;t=t+dt) { */
|
|
/* printf("%f\t%f\n",t,E*(1-exp(-t/tau))); */
|
|
/* } */
|
|
|
|
float v;
|
|
v=0;
|
|
int i;
|
|
|
|
float s = 2.**2;
|
|
printf("%f\t%f\t%f\n",0.0,v,E*(1-exp(-0*dt/tau)));
|
|
for(i=1;i<N;i=i+1) {
|
|
v=v+dt/tau*(E-v);
|
|
printf("%f\t%f\t%f\n",i*dt,v,E*(1-exp(-i*dt/tau)));
|
|
}
|
|
|
|
|
|
}
|