Register to reply 
Troubleshooting FFT code with MATLAB 
Share this thread: 
#1
Jan1514, 10:51 AM

P: 272

ok I wrote my own FFT class and I now have MatLab on my computer. I am comparing my code to matlab.
so my test i used it this :
now the problem is the fft itself: my code gets:
is there a way to get Matlab to print out the steps it is during where it does the FFT? is there a better way of troubleshooting my ftt code ? 


#2
Jan1514, 11:10 AM

Sci Advisor
PF Gold
P: 1,352




#3
Jan1514, 12:21 PM

P: 1,084

As DrClaude said, test with an impulse and then figure out why you get the wrong answer. With a short impulse you can go step by step by hand. Do you have a standalone c program that you started from that works? Can you compare intermediate results with that?



#4
Jan1514, 12:23 PM

P: 272

Troubleshooting FFT code with MATLAB
but I do not know what the outcome of that sequence should be...



#6
Jan1514, 03:33 PM

P: 272

ok i did
y = 1,0,i,0 math lab got :
and my code got:
that is after I get a0 and a2 alone and add then and subject them . the 1st time we get to that code it should be x(0) = a0 + a2 = 1 + i x(1)= a0  a2 = 1  i right? but i am getting x(0) = 1 x(0) = 1 I think it is because the temp4 is wrong.. the 1st Complex1 is called is returns 1 but I do not know how to fix it here is the function
can you help I know it is something wrong with that part of the code 


#7
Jan1614, 08:39 AM

P: 272

in fft
does W^{K}_{N} = (e^{i (2π/N)})^{K} where K is the x[K] or the index of that point and N is the over all number of samples taking I am new to FFT and I am not sure if I am right 


#8
Jan1614, 05:02 PM

P: 272

can someone please tell me how to get W^{K}_{n}?
when you are doing a 8 or a 4 point say you have x = [ 2 , 1, 1, 3, 0, 1 ,2 , 1] x[0] 2 2 butterfly diagram x[4] 0 2 x[2] 1 1 butterfly diagram x[6] 2 3 ok now how do you get 1 and 3 ? (1 + 6 W^{6}_{8}) right ? and that should be a i? can someone please help me I am so lost right now 


#9
Jan1614, 09:10 PM

P: 272

butterfly diagram
can someone please explain me how how you know where K and N are for W^{k}_{N} ? I found this : http://www.google.com/imgres?sa=X&bi...tart=0&ndsp=16 but I do not know how you know when k =0 and when N = 4. can someone please explain this to me? 


#10
Jan1614, 09:29 PM

P: 588

I would focus on the DC component. Your code is producing a DC component of 15.64. The FFT is indicating 0 DC. The DC component is just the mean value of the waveform samples. Walk through your code and see if you can see why that is happening.



#11
Jan1614, 10:54 PM

P: 272

I need to know how W^{k}_{n}
is pick or set.. my code works but only for 4 points and I can only do 4 points by hand i need to know how k and n or know for the W i can see it if i look up a picture of a butterflies diagram on Google but I do not know how they pick/know what k and n is along the butterflies diagram can someone please help me?? can someone please explain that to me? 


#12
Jan1714, 07:27 PM

Mentor
P: 21,281

I didn't realize you had another thread on this.
Matlab results (1 through 4) 1.0000 + 1.0000i 1.0000  1.0000i 1.0000 + 1.0000i 1.0000  1.0000i Your results (1 through 4) 1 + 1i OK 1 + 0i Different 0 + 0i Different 1 + 0i Different It might be easier to spot the differences if you format the two sets of results in the same way. 


Register to reply 
Related Discussions  
Please I need a Help with matlab code (Controlling the LEGO NXT Using MatLab)  Math & Science Software  5  
Matlab R2011a's new feature: portable C/C++ code directly from MATLAB  Math & Science Software  1  
Need help on Matlab code  Programming & Computer Science  1  
MATLAB code help  Math & Science Software  1  
Matlab code  Math & Science Software  0 