使用matlab向数据添加白高斯噪声
add white guassian noise to data with matlab
我正在尝试解决电网的状态估计问题。在电网中,有测量装置测量一些量,如电压大小、来自线路的功率流等,并将它们发送到控制中心。我有一个用 matlab 编写的状态估计代码,它将这些测量值作为输入并确定网格的状态。
所以,我想为网格创建一个测量集。我有一组无噪声测量,我想以特定的标准偏差(比如 5%)向它们添加高斯噪声。我怎样才能做到这一点?这个 5% 的标准差是什么意思(百分比是相对于什么?)
预先感谢您的帮助
您可以在以下位置查看标准偏差的概念:
https://en.wikipedia.org/wiki/Standard_deviation
您可以使用 randn 或 awgn 执行此操作,请参阅:
https://es.mathworks.com/help/comm/ref/awgn.html
https://es.mathworks.com/help/matlab/ref/randn.html
这是一个示例测试,我认为可以根据您的需求进行调整:
close all
A=1; %Amplitude
p=5; %Deviation percentage
n=4;
x = linspace(0,n*pi,1000);
y=A*sin(x);
figure;
plot(x,y)
%Adding Noise
DesiredSD = A*p/100; % the desired standard deviation
noise=DesiredSD*randn(1,1000);
y_gaussian_noise =y+noise;
y_g=y+awgn(y,p,'measured');
figure;
plot(x,noise);
figure;
plot(x,y,x,y_gaussian_noise,x,y_g,'linewidth',1.2);
xlabel('Time(s)');
ylabel('Signal');
legend('without noise', 'with noise','awgn generator');
我正在尝试解决电网的状态估计问题。在电网中,有测量装置测量一些量,如电压大小、来自线路的功率流等,并将它们发送到控制中心。我有一个用 matlab 编写的状态估计代码,它将这些测量值作为输入并确定网格的状态。 所以,我想为网格创建一个测量集。我有一组无噪声测量,我想以特定的标准偏差(比如 5%)向它们添加高斯噪声。我怎样才能做到这一点?这个 5% 的标准差是什么意思(百分比是相对于什么?) 预先感谢您的帮助
您可以在以下位置查看标准偏差的概念:
https://en.wikipedia.org/wiki/Standard_deviation
您可以使用 randn 或 awgn 执行此操作,请参阅:
https://es.mathworks.com/help/comm/ref/awgn.html
https://es.mathworks.com/help/matlab/ref/randn.html
这是一个示例测试,我认为可以根据您的需求进行调整:
close all
A=1; %Amplitude
p=5; %Deviation percentage
n=4;
x = linspace(0,n*pi,1000);
y=A*sin(x);
figure;
plot(x,y)
%Adding Noise
DesiredSD = A*p/100; % the desired standard deviation
noise=DesiredSD*randn(1,1000);
y_gaussian_noise =y+noise;
y_g=y+awgn(y,p,'measured');
figure;
plot(x,noise);
figure;
plot(x,y,x,y_gaussian_noise,x,y_g,'linewidth',1.2);
xlabel('Time(s)');
ylabel('Signal');
legend('without noise', 'with noise','awgn generator');