필터 지우기
필터 지우기

Why do my amplitude become wrong when I vary the frequency from int to double?

조회 수: 1 (최근 30일)
Nina
Nina 2013년 2월 19일
So I started with this code:
A = 10;
B= 17.6;
C=2;
D=11.2;
phi1 = 2;
phi2 = 5;
phi3 = 1;
phi4 = 0;
Fs = 100;
t = 0:1/Fs:1-1/Fs;
x=A*sin(2*pi*10*t+phi1)+B*cos(2*pi*5*t+phi2)+C*sin(2*pi*2*t+phi3)+D*cos(2*pi*t+phi4);
xdft = fft(x);
magnitude = 2* abs(xdft)/length(x)
phase = angle(2* max((xdft))/length(x))
And that gave me all the amplitudes exactly. However when say I change the first frequency from A*sin(2*pi*10*t+phi1) to A*sin(2*pi*10.5*t+phi1), it goes crazy and give me weird output... what am I doing wrong?
Thank you

답변 (1개)

Wayne King
Wayne King 2013년 2월 19일
It does not go "crazy", it only gets the amplitude wrong for the frequency f = 10.5 and this is problem I explained to you in the other post. 10.5 does not correspond to a DFT bin.
See
  댓글 수: 2
Nina
Nina 2013년 2월 19일
Thank Wayne, I guess I am still trying to understand what is going on...basically, every time I change my frequencies, I need to make sure they fall into appropriate bins?
Nina
Nina 2013년 2월 19일
Also, if 10.5 does not correspond to a DFT bin, how do I deal with it?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Spectral Measurements에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by