how to draw a spectrum for a sine wave in frequency domain?and what is central frequency/2 of time domain and frequency domain ?
22 views (last 30 days)
Show older comments
good morning friends,
0 Comments
Answers (1)
Hari
on 24 Feb 2025
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 Comments
See Also
Categories
Find more on Spectral Measurements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!