matlab代码实现EEG单通道数据的功率谱密度图像输出
时间: 2023-05-31 07:03:34 浏览: 127
功率谱计算附matlab代码
以下是matlab代码实现EEG单通道数据的功率谱密度图像输出的示例代码:
```matlab
%读取EEG单通道数据
eeg_data = load('eeg_single_channel_data.mat'); %假设数据文件名为'eeg_single_channel_data.mat'
eeg_data = eeg_data.eeg_single_channel_data; %假设数据存储在变量'eeg_single_channel_data'中
%设置参数
fs = 250; %采样率
window_size = 5; %窗口大小(单位:秒)
overlap = 0.5; %窗口重叠率
%计算功率谱密度
window_samples = round(fs * window_size); %窗口大小(单位:样本数)
overlap_samples = round(window_samples * overlap); %窗口重叠样本数
[Pxx,f] = pwelch(eeg_data,window_samples,overlap_samples,[],fs);
%绘制功率谱密度图像
figure;
plot(f,Pxx);
title('Power Spectral Density');
xlabel('Frequency (Hz)');
ylabel('Power/Frequency (dB/Hz)');
```
阅读全文