高分悬赏!急求!三角波,锯齿,正弦波,脉冲的C语言程序代码,不要单片机方面的,纯C的!

如题,就是在VC里面可以编译通过,谢谢
2025-04-03 12:31:11
推荐回答(2个)
回答1:

正弦波输入 振幅,频率,时步,相位
三角波锯齿波输入 振幅,坡1宽,坡2宽,无波宽,时步
三角波 w1=w2, 锯齿波 w1 != w2.
程序没有考虑时间 宽度w1=0 或 w2 =0,如果等于0,请给一个非0值,例如 0.0000001.

脉冲方波,请自己模仿三角波程序计算。w期间等于amp,flat_t期间等于0.

#include
#include

void main()
{
double y[2048];
double pi,r;
double amp,f,phi,dt,t,x;
double w,flat_t,slop1,slop2,L,w1,w2;
int flag_w1=0,flag_w2=0;
long int i;
int N=2048;
char str[5];

pi = atan(1.0) * 4.0;

fprintf(stderr,"Enter sin or tri\n");
scanf("%s",&str[0]);

if ( strncmp(str,"sin",3) == 0)
{
fprintf(stderr,"enter Amp Hz delta_t phase\n");
fprintf(stderr,"for example: 1.0 10.0 0.001 1.414\n");

scanf("%lf %lf %lf %lf",&,&f,&dt,&phi);
for (i=0;i
for (i=0;iexit(0);
};

fprintf(stderr,"enter Amp w1 w2 flat_t dt\n");
fprintf(stderr,"for example: 1. 1. 1. 1. 0.01 \n");
scanf("%lf %lf %lf %lf %lf",&,&w1,&w2,&flat_t,&dt);
w = w1+w2;
L = w + flat_t;
slop1 = amp / w1;
slop2 = -amp / w2;

for (i=0;i{
t = dt * (double) i;
x = t - L * (double) ( (int) (t / L));
if (x >= 0.0 && x <= w1) y[i] = slop1 * x;
if (x > w1 && x < w ) y[i] = amp + slop2 * (x - w1);
if (x >= w && x <= L ) y[i] = 0.0;
}

for (i=0;iexit(0);

}

回答2:

笑话,没有硬件支持,怎么产生?