C:\Users\DELL\Desktop\lms\main.c|20|error: lvalue required as increment operand|
C:\Users\DELL\Desktop\lms\main.c|21|error: lvalue required as increment operand|
C:\Users\DELL\Desktop\lms\main.c|30|error: expected ';' before 'for'|
C:\Users\DELL\Desktop\lms\main.c|42|error: expected ';' before ')' token|
C:\Users\DELL\Desktop\lms\main.c|42|error: expected statement before ')' token|
C:\Users\DELL\Desktop\lms\main.c|44|warning: control reaches end of non-void function
#include <stdio.h>
#include <stdlib.h>
#include<math.h>
#define beta 0.01 //convergence rate
#define N 21 //order of filter
#define NS 40 //number of samples
#define Fs 8000 //sampling freqency
#define pi 3.1415926
#define DESIRED 2*cos(2*pi*T*1000/Fs) //desired signal
#define NOISE sin(2*pi*T*1000/Fs) //noise signal
int main()
{
long I,T;
double D, Y, E;
double W[N+1] = {0.0};
double X[N+1] = {0.0};
FILE*desired,*Y_out, *error;
desired = fopen ("desired", "W++"); //file for desired samples
Y_out = fopen ("Y_out", W++); //file for output samples
error = fopen ("ERROR", W++); //file for error samples
for (T = 0; T < NS; T++) //start adaptive algorithm
{
X[0] = NOISE; //new niose sample
D = DESIRED; //desired signal
Y = 0; //filter'output set to zero
for (I = 0; I <= N; I++)
Y += (W[I] * X[I]); //calculate filter output
E = D - Y //calculate error signal
for (I = N; I >= 0, I--)
{
W[I] += (beta*E*X[I]); //update filter coefficients
if (I != 0)
X[I] = X[I-1]; //update data sample
}
fprintf (desired, "\n%g %10f",(float) T/Fs,D);
fprintf (Y_out, "\n%g %10f",(float) T/Fs,Y);
fprintf (error, "\n%g %10f",(float) T/Fs,E);
}
fclose (desired);
fclose (Y_out));
fclose (error);
}
uj5u.com熱心網友回復:
E = D - Y 這兒缺少分號,這是一個錯誤,其他的你再看uj5u.com熱心網友回復:
E=D-Y處沒有報錯,是在我標紅的地方報錯了。uj5u.com熱心網友回復:
#include <stdio.h>#include <stdlib.h>
#include<math.h>
#define beta 0.01 //convergence rate
#define N 21 //order of filter
#define NS 40 //number of samples
#define Fs 8000 //sampling freqency
#define pi 3.1415926
#define DESIRED 2*cos(2*pi*T*1000/Fs) //desired signal
#define NOISE sin(2*pi*T*1000/Fs) //noise signal
int main()
{
long I,T;
double D, Y, E;
double W[N+1] = {0.0};
double X[N+1] = {0.0};
FILE*desired,*Y_out, *error;
desired = fopen ("desired", "W+"); //file for desired samples
Y_out = fopen ("Y_out", "W+"); //file for output samples
error = fopen ("ERROR", "W+"); //file for error samples
for (T = 0; T < NS; T++) //start adaptive algorithm
{
X[0] = NOISE; //new niose sample
D = DESIRED; //desired signal
Y = 0; //filter'output set to zero
for (I = 0; I <= N; I++)
Y += (W[I] * X[I]); //calculate filter output
E = D - Y; //calculate error signal
for (I = N; I >= 0; I--)
{
W[I] += (beta*E*X[I]); //update filter coefficients
if (I != 0)
X[I] = X[I-1]; //update data sample
}
fprintf (desired, "\n%g %10f",(float) T/Fs,D);
fprintf (Y_out, "\n%g %10f",(float) T/Fs,Y);
fprintf (error, "\n%g %10f",(float) T/Fs,E);
}
fclose (desired);
fclose (Y_out);
fclose (error);
}
uj5u.com熱心網友回復:
“w+”不是w++uj5u.com熱心網友回復:
也不是W++的問題,我老師給我點了一下,file之后少加了個空格。
改完之后報錯提示變了,但是還是報錯
C:\Users\DELL\Desktop\1\main.c|23|error: stray '\224' in program|
C:\Users\DELL\Desktop\1\main.c|23|error: expected expression before ')' token|
C:\Users\DELL\Desktop\1\main.c|19|warning: variable 'Y_out' set but not used [-Wunused-but-set-variable]|
C:\Users\DELL\Desktop\1\main.c|18|warning: variable 'desired' set but not used [-Wunused-but-set-variable]|
C:\Users\DELL\Desktop\1\main.c|17|warning: unused variable 'X' [-Wunused-variable]|
C:\Users\DELL\Desktop\1\main.c|16|warning: unused variable 'W' [-Wunused-variable]|
C:\Users\DELL\Desktop\1\main.c|15|warning: unused variable 'E' [-Wunused-variable]|
C:\Users\DELL\Desktop\1\main.c|15|warning: unused variable 'Y' [-Wunused-variable]|
C:\Users\DELL\Desktop\1\main.c|15|warning: unused variable 'D' [-Wunused-variable]|
C:\Users\DELL\Desktop\1\main.c|14|warning: unused variable 'T' [-Wunused-variable]|
C:\Users\DELL\Desktop\1\main.c|14|warning: unused variable 'I' [-Wunused-variable]|
C:\Users\DELL\Desktop\1\main.c|46|warning: control reaches end of non-void function [-Wreturn-type]|
||=== Build 失敗了: 5 error(s), 11 warning(s) (0 minute(s), 0 second(s)) ===|
uj5u.com熱心網友回復:
你的程式,小問題太多了,先把基本的語法搞清楚。轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/60213.html
標籤:C語言
上一篇:那個大佬求解
下一篇:牛頓迭代法求多元方程近似根
