Can somebody trace my error in this solution of spectrum
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I have found the frequency spectrum of signal x=(4+cos(1000*pi*t+pi/3)).*(sin(500*pi*t+pi/4))
There is slight difference in my hand calculation amplitude and amplitude by Matlab. By me, the amplitude at 250 Hz is 2 and by Matlab it is 1.8
My solution is attached here
The matlab code is here
Fs = 2000;
t = 0:1/Fs:1-(1/Fs);
x=(4+cos(1000*pi*t+pi/3)).*(sin(500*pi*t+pi/4));
%x=(4+cos(40*pi*t)).*(cos(200*pi*t-pi/2));
%x=cos(pi*t).*(sin(10*pi*t));
xdft = (1/length(x))*fft(x);
freq = -1000:(Fs/length(x)):1000-(Fs/length(x));
plot(freq,abs(fftshift(xdft)))
xlabel('Freq(Hz)-------->')
ylabel('Amplitude')
Kindly tell me abt my error
and more thing, if at two points, we have freq component, what happen to them, are they added or the lower one is merged in it
0 Commenti
Risposta accettata
Wayne King
il 2 Ott 2011
If a negative term appears associated with a single frequency, like say
-2*exp(1j*pi/4) that has no impact on magnitude that is just a pi phase shift.
-2*exp(1j*pi/4) = 2*exp(1j*pi/4-pi) % or +pi
remember exp(1j*pi) = exp(-1j*pi) = -1
where it did make a difference is when you had terms that had the same frequency because as you saw you ended with a magnitude you didn't expect.
Remember a magnitude is real-valued and non-negative.
Più risposte (7)
moonman
il 2 Ott 2011
1 Commento
Walter Roberson
il 2 Ott 2011
When you are posting and hoping for a fast response, it is best if you keep in mind the time and date it would be in North America. The majority of the people who volunteer to answer MATLAB questions are in eastern United States, which is GMT-0500 during the winter, GMT-0400 during the summer, and two of the more frequent volunteers are one timezone further over, GMT-0600 during the winter, GMT-0500 during the summer. When you post at 0930 UTC, that is only 0530 in the eastern US in summer, 0430 for those two volunteers. On what, to them, is a Sunday. If you manage to get anyone in those two timezones at all on a Sunday morning, they would either be just barely awake from letting the dog out, or very tired from having stayed up all night.
There _are_ some volunteers in western Europe who answer, but most of them do things with their families on Sunday mornings.
Wayne King
il 2 Ott 2011
The sine terms at 250 Hz interact such that the magnitude of the sum is not 2 (when you look at the two-sided spectrum).
What you end up with at that frequency is
4*sin(2*pi*250*t+pi/4)-1/2*sin(2*pi*250*t+pi/12)
If you look at the magnitude spectrum of that:
Fs = 4e3;
t = 0:1/Fs:1-(1/Fs);
x = 4*sin(2*pi*250*t+pi/4)-(1/2)*sin(2*pi*250*t+pi/12);
xdft = (1/length(x))*fft(x);
freq = -2000:(Fs/length(x)):2000-(Fs/length(x));
plot(freq,abs(fftshift(xdft)))
xlabel('Freq(Hz)-------->')
ylabel('Amplitude')
max(abs(fftshift(xdft)))
You see where the magnitude comes from.
0 Commenti
moonman
il 2 Ott 2011
1 Commento
Wayne King
il 2 Ott 2011
I think that is misleading because the two terms interact. Remember the triangle inequality: for complex number z and w |z+w| <= |z| + |w|.
What you have is |z+w|
You only have one frequency term at that point in the spectrum. Take an extreme case: imagine I have a cos(omega *t) and cos(omega*t-pi) and I add them together. Does it make sense to show 2 amplitudes of 1/2 at -omega and omega?
moonman
il 2 Ott 2011
3 Commenti
Wayne King
il 2 Ott 2011
No, j is the unit imaginary so that cannot appear in the magnitude. The magnitude of any complex number is purely real, j is the number 0+j or (0,1) if you want to think of a complex number as an ordered pair of real numbers.
j is always associated with phase. In fact, you can write:
2*j exp(j*pi/4) = 2*exp(j(pi/4+pi/2))
Test this in MATLAB:
isequal(2*1j*exp(j*pi/4),2*exp(1j*3*pi/4))
in both cases the magnitude is just 2.
Sim
il 2 Ott 2011
**well, I made a typo in my answer, and just to corroborate what wayne said, in the exponential, I should have written j*pi/4+j*pi/2, not j*pi/4+j*pi.
Vedere anche
Categorie
Scopri di più su Spectral Measurements in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!