fft using matlab

Discussion in 'Programmer's Corner' started by Marie, Feb 10, 2008.

  1. Marie

    Thread Starter Member

    Nov 20, 2007
    24
    0
    Hi,

    I had to design a three phase four wire system supplying non linear loads using simulink. The aim was to obtain the harmonic content generated by these loads. I was successful in the design. However, I could not get the fft using the powergui from simpowersystems (for some unknown reasons it is not available on my cd). So, I've tried to send the data to workspace where i have written an M-file to generate the fft.

    Unfortunately, it does not seem to be that easy. I fail to get the harmonic frequencies and I just can't interprete the graph i have obtained. It does not make sense since the ac current has a fundamental at 50Hz and the graph i obtain contains just a dc component.

    I've attached a schematic of the circuit i simulated + M-file.

    Can anyone suggest an easier way to get the harmonic content?

    Thanks
     
  2. Dave

    Retired Moderator

    Nov 17, 2003
    6,960
    145
    What is wrong with the core Matlab FFT function?

    Dave
     
  3. Marie

    Thread Starter Member

    Nov 20, 2007
    24
    0
    Hi,

    Well probably i don't know how to interprete the graph but there are a few queer things:

    1) i'm measuring the supply current which is ac with fundamental at 50 Hz n the graph shows me a dc component only.

    2) then, i would expect to get the magnitude of the current to be around 2A but the y-axis seems to represent something else.

    Well, for (2) it is possible that the yaxis scale is according to DFT so that i should consider the length of sequence etc[sorry but my knowledge of DFT is quite limited], but what about the frequency?

    This is why i'm looking for another way or a way to correct the one i proposed.

    Thanks
     
  4. koco

    New Member

    Oct 22, 2008
    1
    0
    Hi,
    Is seems that you did not use a frequency series to display x-axis in a proper way. It is not included in attached file. If there are a lot of N-points in FFT it is possible to obtain long output array.
    You could do sth like this:
    Code ( (Unknown Language)):
    1.  
    2. [FONT=Courier New][SIZE=2]ff = 50;              [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#228b22]% Fundamental frequency[/COLOR][/SIZE][/FONT]
    3. [FONT=Courier New][SIZE=2]T = 1/ff;[/SIZE][/FONT]
    4. [SIZE=2][FONT=Courier New]t_start = 0;[/FONT][/SIZE]
    5. [SIZE=2][FONT=Courier New]t_end = 1*T;[/FONT][/SIZE]
    6. [SIZE=2][FONT=Courier New]fs = 1e4;             [/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#228b22]% Sampling frequency[/COLOR][/SIZE][/FONT]
    7. [FONT=Courier New][SIZE=2]Ts = 1/fs;            [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#228b22]% Sample time[/COLOR][/SIZE][/FONT]
    8. [FONT=Courier New][SIZE=2]t = t_start:Ts:t_end; [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#228b22]% Time vector[/COLOR][/SIZE][/FONT]
    9. [FONT=Courier New][SIZE=2]L = size(t,2);[/SIZE][/FONT]
    10. [FONT=Courier New][SIZE=2]N = 2^nextpow2(L);[/SIZE][/FONT]
    11. [FONT=Courier New][SIZE=2]Y = fft(y,N);[/SIZE][/FONT]
    12. [FONT=Courier New][SIZE=2]f = fs/N*(0:N/2-1);[/SIZE][/FONT]
    13. [SIZE=2][FONT=Courier New][FONT=Courier New][SIZE=2]plot(f,2*abs(Y(1:N/2))),[FONT=Courier New][SIZE=2]xlim([0 5*ff]),[/SIZE][/FONT][/SIZE][/FONT][/FONT][/SIZE]
    Hope it helps.
    koco
     
Loading...