Guest User

Untitled

a guest
Jun 25th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.63 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3. #include <time.h>
  4. #include <stdlib.h>
  5.  
  6. double function(double t, double k1, double phase)
  7.     {
  8.    
  9.     double k2=10,m=1;
  10.     double x;
  11.    
  12.     x= log(t+1)*cos(k1*k2*t+phase)*exp(-t/2);
  13.    
  14.     return x;
  15. }
  16.  
  17. main()
  18.     {
  19.     srand(time(NULL));
  20.     double time=.0001, v=1, phase,xvalue,yvalue=0, k1;
  21.     double loop=1;
  22.     FILE *out;
  23.     out=fopen("simulation.csv","w");
  24.        
  25.     while (loop<5)
  26.         {
  27.         phase= loop*3.14/3;
  28.    
  29.        
  30.         while (time<10)
  31.             {
  32.             yvalue=v*time;
  33.             xvalue=function(time,v,phase);
  34.        
  35.             fprintf(out,"%e,%e\n",xvalue,-yvalue);
  36.        
  37.             time=time+.001;
  38.         }
  39.         loop=loop+1;
  40.    
  41.         time=.00001;
  42.     }
  43. }
Add Comment
Please, Sign In to add comment