matlab specgram
时间: 2023-11-02 11:07:49 浏览: 42
The specgram function in MATLAB is used to generate a spectrogram, which is a visual representation of the frequency content of a signal over time. The function takes in a signal and a window size, and outputs a matrix with the frequency content of the signal at each time step.
Here is an example usage of the specgram function:
```matlab
% Generate a signal
fs = 1000; % Sampling frequency
t = 0:1/fs:1; % Time vector
f = 100; % Frequency of the signal
x = sin(2*pi*f*t); % Sinusoidal signal
% Plot the spectrogram
window_size = 256;
specgram(x, window_size, fs);
```
This code generates a sinusoidal signal with a frequency of 100 Hz and a length of 1 second. The signal is then passed to the specgram function with a window size of 256 samples and a sampling frequency of 1000 Hz. The resulting spectrogram is plotted, showing the frequency content of the signal over time.
相关推荐
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)