Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

MATLAB - FFT - different result - why?

Status
Not open for further replies.

powersys

Advanced Member level 1
Joined
Nov 29, 2005
Messages
439
Helped
3
Reputation
6
Reaction score
2
Trophy points
1,298
Activity points
4,981
I encounter the following problem. Kindly advise.


Fig0 -> Configuration Parameters


Fig1 -> Simulink model


Fig2 -> Source Block Parameters: "Sine Wave1" & "Sine Wave2".
"Sine Wave1" and "Sine Wave2" are configured to have similar amplitude, frequency, phase, and sample time.



Fig3 -> Output of "Vector Scope1" and "Vector scope2"



Questions:
[1] "Vector Scope1" shows peak=1.0V at 1.5kHz, whilst "Vector Scope2" shows peak=2.0V at 1.5kHz. Why do they have different peak magnitudes at 1.5kHz?

[2] It looks to me that the outputs of "Sine Wave1" and "Sine Wave2" are different. Why?


Thanks



Code:
%%% Global Parameters
endTIME=1;

bufferSIZE=1024;
fftLENGTH=1024;

fs=8e3;
Ts=1/fs;

a1=1;
f1=1500;
phaseshift1=0;


%%% Function Block Parameters: Buffer1 (Buffer2)
Output buffer size: bufferSIZE
Buffer overlap: 0
Initial conditions: 0


%%% Function Block Parameters: Pad1 (Pad2)
Pad over: Columns
Pad value source: Specify via dialog
Pad value: 0
Output column mode: User-specified
Column size: fftLENGTH
Action when truncation occurs: None


%%% Function Block Parameters: FFT1 (FFT2)
Main -> Twiddle factor computation: Table lookup
Optimize table for: Speed
Output in bit-reversed order: unchecked
Divide butterfly outputs by two: unchecked
Inherit FFT length from input dimensions: unchecked
FFT length: fftLENGTH


%%% Function Block Parameters: Gain1 (Gain2)
Gain: 2/fftLENGTH
Multiplication: Element-wise(K.*u)
Sample time: -1


%%% Sink Block Parameters: Vector Scope1 (Vector Scope2)
Under "Axis Properties" tab:
Frequency units: Hertz
Frequency range: [0...Fs/2]
Inherit sample time from input: checked
Frequency display limits: Auto
Amplitude: Magnitude
Minimum Y-limit: -0.5
Maximum Y-limit: 3
Y-axis title: Amplitude
 

Could it be due to the Gain in the two schemes!
 

The FFT processing block (in blue rectangular box) connected to "Sine Wave 2" is the same as that connected to "Sine Wave 1". Therefore, the gain should be the same. Kindly advise.
 

Hi
Change the Output complexity of the Sine Wave 2 to Real.
You should then get the same peaks. :)
 

Thanks MHanif. What's the difference between the sinewaves generated by Sine Wave 2 with/without Output Complexity set as "complex"?
 

For Complexity = Real, the output is simple sin(ωt + Θ) depending on the initial phase.

And

For Complexity = complex, the output is simple cos(ωt + Θ)+j*sin(ωt + Θ) depending on the initial phase.

I think you will now realize why did you get twice the peak value :D.
 

    powersys

    Points: 2
    Helpful Answer Positive Rating
Thanks MHanif. Would you please help in another problem posted here:
 

LOOOOOOOOOOOOOOOOOOOOOL

it's so easyyy, just the 2nd sine wave amplitude is double the amplitude of the 1st sin :DDD hahahahahaaaa

what a problem !! :DD
 

mando88eg did not read the question carefully...
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top