⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lms_flp32.m

📁 基于TS201 Floating Point LMS Filter
💻 M
字号:
%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);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -