#include #include #include #define SAMPLEF 8000.0 int main(int a, char *p[]){ if(a>4){ printf("\e[31mMoc argumentu\e[0m\n"); exit(1); } double omega,u,f,um,t,ts,dsp1=0.0,dsp2=0.0; um = atof(p[1]); //amplituda f = atof(p[2]); //kmitocet ts = atof(p[3]); //trvani if(um<1 || f<1 || ts<0){ printf("\e[31mNezaporuj\e[0m\n]"); exit(2); } printf("\e[33mum %lf f %lf ts %lf\e[0m\n",um,f,ts); omega=2.0*M_PI*f; double tht=omega/SAMPLEF; double costht=2.0*cos(tht); double ud=sin(tht); int j = ts*SAMPLEF; printf("\e[32mj %d omega %lf tht %lf\e[0m\n",j,omega,tht); t = 0.0; //printf("%lf %lf %lf\n",0,0,0); printf("0.000000 0.0000 0.0000\n"); for(int i = 0; i < j; i++){ t+=1/SAMPLEF; //cas u=um*sin(omega*t); //u pomoci sinus printf("%lf %3.4lf %3.4lf\n",t,u,um*ud); //cas u_sin u_dsp dsp1=ud; ud=costht*dsp1-dsp2; //u pomoci dsp dsp2=dsp1; } return 0; }