TigerSharc TS201 floating point lms filter routine

源代码在线查看: lms_flp32.m

软件大小: 18 K
上传用户: wzsq12
关键词: TigerSharc floating routine filter
下载地址: 免注册下载 普通下载 VIP

相关代码

				%this file takes the content of input.dat, desired.dat files and computes
				%the LMS filter. The file output_m.dat must be identical with the file
				%outdata.dat .
				
				format long
				clear all
				
				T=16;
				epsilon=0.3;
				
				fid = fopen('test1\input.dat', 'r');
				      [input, count] = fscanf (fid, '%e');
				fclose(fid);
				
				[N, x] = size(input); %N=the size of input buffer
				
				
				fid = fopen('test1\desired.dat', 'r');
				      [des, count] = fscanf (fid, '%e');
				fclose(fid);
				
				for i=1:T
				    xs(i)= 0;
				    e(i)=0;
				    c(i)=0;
				end;
				
				for i=1:N-1
				    xs(1)=input(i);
				    output=0;
				    for j=1:T
				        output=output+c(j)*xs(j);
				    end
				    y(i)=output;
				    e(i)=des(i)-y(i);
				
				%c(1) corresponds to h(0) from the assembly program
				    for j=1:T
				        c(j)=c(j)+epsilon*e(i)*xs(j);
				    end;
				
				    for j=T:-1:2
				        xs(j)=xs(j-1);
				    end;
				end;
				
				i=N;
				    xs(1)=input(i);
				    output=0;
				    for j=1:T
				        output=output+c(j)*xs(j);
				    end
				    y(i)=output;
				    e(i)=des(i)-y(i);
				
				
				
				fin = fopen('test1\output_matlab.dat', 'wt');
				for i=1:N
				    fprintf(fin, '%f\n', y(i));
				end;
				fclose(fin);
				
				fin = fopen('test1\coeff_matlab.dat', 'wt');
				
				    fprintf(fin, '%f\n', c(16));
				    fprintf(fin, '%f\n', c(12));
				    fprintf(fin, '%f\n', c(8));
				    fprintf(fin, '%f\n', c(4));
				    fprintf(fin, '%f\n', c(15));
				    fprintf(fin, '%f\n', c(11));
				    fprintf(fin, '%f\n', c(7));
				    fprintf(fin, '%f\n', c(3));
				    fprintf(fin, '%f\n', c(14));
				    fprintf(fin, '%f\n', c(10));
				    fprintf(fin, '%f\n', c(6));
				    fprintf(fin, '%f\n', c(2));
				    fprintf(fin, '%f\n', c(13));
				    fprintf(fin, '%f\n', c(9));
				    fprintf(fin, '%f\n', c(5));
				    fprintf(fin, '%f\n', c(1));
				
				fclose(fin);
				
				%fin = fopen('test1\error_matlab.dat', 'wt');
				%for i=1:N
				%    fprintf(fin, '%f\n', e(i));
				%end;
				%fclose(fin);
				
							

相关资源