From: Heman on 19 Jul 2010 13:51 Hi all, I am trying to run this matlab code but am facing with a few errors. Can some one help me out? I ran this code with a random input signal and it was working. Now i tried running with the input file which has 1024 hexadecimal values. clear all; close all; clc ntaps=64; nsamp=1024; ibeta=2^2; % mu= 0.25 fid = fopen('data.txt', 'r'); refsig = fscanf(fid, '%x'); %amp=0.5; %refsig = amp*rand (1,nsamp) - (amp/2); %t = [0:1:1023]; Wn= 0.47; B= fir1(30,Wn); x=filter(B,1,refsig); x=x'; coeff=fir1(ntaps, 0.5); d= filter(coeff,1,x); h(1:ntaps)=0; %figure(2) subplot (3,2,1) plot(h); title('coefficients,h'); subplot (2,2,2) plot(x); %plot (refsig); title('Input signal,x'); for n=1:nsamp if n<= ntaps x1=[x(n:-1:1)' zeros(1,ntaps-n)]; else x1=x(n:-1:n-ntaps+1)'; end y(n)=x1*h'; e(n)=d(n)-y(n); hh=e(n)*x1/ibeta; h=h+hh; end subplot (2,2,3) plot(h); title('coefficients, h=h+hh'); subplot (2,2,4) plot(e); title('Error, e'); Please help me out friends. Thank you
From: someone on 19 Jul 2010 14:25 "Heman " <kokahemant(a)hotmail.com> wrote in message <i223ab$2d6$1(a)fred.mathworks.com>... > Hi all, > > I am trying to run this matlab code but am facing with a few errors. Can some one help me out? > I ran this code with a random input signal and it was working. Now i tried running with the input file which has 1024 hexadecimal values. > > clear all; > close all; > clc > > ntaps=64; > nsamp=1024; > ibeta=2^2; % mu= 0.25 > > fid = fopen('data.txt', 'r'); > refsig = fscanf(fid, '%x'); > > %amp=0.5; > %refsig = amp*rand (1,nsamp) - (amp/2); > %t = [0:1:1023]; > Wn= 0.47; > B= fir1(30,Wn); > x=filter(B,1,refsig); > x=x'; > coeff=fir1(ntaps, 0.5); > d= filter(coeff,1,x); > h(1:ntaps)=0; > > %figure(2) > subplot (3,2,1) > plot(h); > title('coefficients,h'); > > subplot (2,2,2) > plot(x); > %plot (refsig); > title('Input signal,x'); > > for n=1:nsamp > > if n<= ntaps > x1=[x(n:-1:1)' zeros(1,ntaps-n)]; > else > x1=x(n:-1:n-ntaps+1)'; > end > > y(n)=x1*h'; > e(n)=d(n)-y(n); > hh=e(n)*x1/ibeta; > h=h+hh; > > end > > subplot (2,2,3) > plot(h); > title('coefficients, h=h+hh'); > > subplot (2,2,4) > plot(e); > title('Error, e'); > > Please help me out friends. > > Thank you Since we don't have the input file, its hard to say what could be the problem. It would help us if you said what the errror messages were a least.
From: Heman on 19 Jul 2010 14:43 "someone" <someone(a)somewhere.net> wrote in message <i225ai$afo$1(a)fred.mathworks.com>... > "Heman " <kokahemant(a)hotmail.com> wrote in message <i223ab$2d6$1(a)fred.mathworks.com>... > > Hi all, > > > > I am trying to run this matlab code but am facing with a few errors. Can some one help me out? > > I ran this code with a random input signal and it was working. Now i tried running with the input file which has 1024 hexadecimal values. > > > > clear all; > > close all; > > clc > > > > ntaps=64; > > nsamp=1024; > > ibeta=2^2; % mu= 0.25 > > > > fid = fopen('data.txt', 'r'); > > refsig = fscanf(fid, '%x'); > > > > %amp=0.5; > > %refsig = amp*rand (1,nsamp) - (amp/2); > > %t = [0:1:1023]; > > Wn= 0.47; > > B= fir1(30,Wn); > > x=filter(B,1,refsig); > > x=x'; > > coeff=fir1(ntaps, 0.5); > > d= filter(coeff,1,x); > > h(1:ntaps)=0; > > > > %figure(2) > > subplot (3,2,1) > > plot(h); > > title('coefficients,h'); > > > > subplot (2,2,2) > > plot(x); > > %plot (refsig); > > title('Input signal,x'); > > > > for n=1:nsamp > > > > if n<= ntaps > > x1=[x(n:-1:1)' zeros(1,ntaps-n)]; > > else > > x1=x(n:-1:n-ntaps+1)'; > > end > > > > y(n)=x1*h'; > > e(n)=d(n)-y(n); > > hh=e(n)*x1/ibeta; > > h=h+hh; > > > > end > > > > subplot (2,2,3) > > plot(h); > > title('coefficients, h=h+hh'); > > > > subplot (2,2,4) > > plot(e); > > title('Error, e'); > > > > Please help me out friends. > > > > Thank you > > > Since we don't have the input file, its hard to say what could be the problem. > > It would help us if you said what the errror messages were a least. I cannot put the input file as its 1024 hexadecimal data. so its a very big file. I dont know if there is an option of attaching the files here. The eror messages: ??? Error using ==> horzcat CAT arguments dimensions are not consistent. Error in ==> lms_prof at 36 x1=[x(n:-1:1)' zeros(1,ntaps-n)]; ********** I then changed the statement to x1=[x(n:-1:1) zeros(1,ntaps-n)]; ******** The next error : ??? Error using ==> mtimes Inner matrix dimensions must agree. Error in ==> lms_prof at 41 y(n)=x1*h'; ***************** The dimentions of h and x1 are 1x64. I changed the statement to y(n)=x1'*h; But still same error. I you want the data file then just let me know i can send an email or if i can attach here then please tell me. I am new to this forum. Thank you
From: Andy on 19 Jul 2010 14:57 > The dimentions of h and x1 are 1x64. Are you sure about this? Are you sure that the number of columns of x1 doesn't depend on the if statement immediately before the problematic line?
From: Heman on 19 Jul 2010 15:03 "Andy " <myfakeemailaddress(a)gmail.com> wrote in message <i22765$8nc$1(a)fred.mathworks.com>... > > The dimentions of h and x1 are 1x64. > > Are you sure about this? Are you sure that the number of columns of x1 doesn't depend on the if statement immediately before the problematic line? yea... i am sure. i am stating what MATLAB is showing.
|
Next
|
Last
Pages: 1 2 3 4 Prev: Powers are slow, multiplies fast; optimized badly? Next: checking/setting part of an array. |