how to draw a spectrum for a sine wave in frequency domain?and what is central frequency/2 of time domain and frequency domain ?
11 次查看(过去 30 天)
显示 更早的评论
回答(1 个)
Hari
2025-2-24
Hi Shri Vishnu,
I understand that you want to draw the frequency spectrum of a sine wave and are curious about the concept of central frequency in both the time and frequency domains.
I assume you have a basic sine wave signal and want to visualize its frequency components using MATLAB.
In order to draw the frequency spectrum of a sine wave and understand the central frequency, you can follow the below steps:
Generate a Sine Wave:
Create a sine wave with a specific frequency and sampling rate.
fs = 1000; % Sampling frequency in Hz
f = 50; % Frequency of sine wave in Hz
t = 0:1/fs:1-1/fs; % Time vector for 1 second
sine_wave = sin(2 * pi * f * t);
Compute the Fourier Transform:
Use the “fft” function to transform the sine wave into the frequency domain.
Y = fft(sine_wave);
L = length(sine_wave);
P2 = abs(Y/L); % Two-sided spectrum
P1 = P2(1:L/2+1); % Single-sided spectrum
P1(2:end-1) = 2*P1(2:end-1);
Define the Frequency Domain:
Create a frequency vector for plotting.
f_axis = fs*(0:(L/2))/L;
Plot the Frequency Spectrum:
Visualize the single-sided amplitude spectrum.
plot(f_axis, P1);
title('Single-Sided Amplitude Spectrum of Sine Wave');
xlabel('Frequency (Hz)');
ylabel('|P1(f)|');
Understanding Central Frequency:
In the time domain, the central frequency is the frequency of the sine wave. In the frequency domain, it refers to the peak frequency, which is the frequency of the sine wave itself.
Refer to the documentation of “fft” function to know more about its usage:
Hope this helps!
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spectral Measurements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!