function x=sr(a,b,h,x1)
x=zeros(1,length(x1));
% for i=1:length(x1)-1
% k1=h*(a*x(i)-b*x(i).^3+x1(i));
% k2=h*(a*(x(i)+k1/2)-b*(x(i)+k1/2).^3+x1(i));
% k3=h*(a*(x(i)+k2/2)-b*(x(i)+k1*(sqrt(2)-1)/2+k2*(2-sqrt(2))/2).^3+x1(i+1));
% k4=h*(a*(x(i)+k3)-b*(x(i)-k2*sqrt(2)/2+k3*(2+sqrt(2))/2).^3+x1(i+1));
% x(i+1)=x(i)+(1/6)*(k1+(2-sqrt(2))*k2+(2+sqrt(2))*k3+k4);
% end
for i=1:length(x1)-1
k1=h*(a*x(i)-b*x(i).^3+x1(i));
k2=h*(a*(x(i)+k1/2)-b*(x(i)+k1/2).^3+x1(i));
k3=h*(a*(x(i)+k2/2)-b*(x(i)+k2/2).^3+x1(i+1));
k4=h*(a*(x(i)+k3)-b*(x(i)+k3).^3+x1(i+1));
x(i+1)=x(i)+(1/6)*(k1+2*k2+2*k3+k4);
End
clear all
clc
A=0.3; %信号幅度
fs=10; %采样频率
f=0.01; %信号频率
Ts=1/fs;%采样时间
h=1/fs; %时间步长
t=0:Ts:4095*Ts;
%双稳态系统参数
a=1;
b=1;
s=A*sin(2*pi*f*t); %信号
for kk=1:1500
disp(kk);
SNR(kk)=kk/50-20;
g=SNR(kk);
x1=AWGN(s,g); %噪声
%输入无噪信号傅立叶变换
y=fft(s,4096);
pyy=y.*conj(y)/4096;
ff=fs*(0:2048)/4096;
max=1;
for i=1:2049
if(pyy(i)>pyy(max))
max=i;