clc,clear all,close all
%----------------------------------------------------------------------------
% Date of Creation 06.08.2015
% Date of Modification 06.08.2015
% To estimate the value of True Signal
% Plot For Mean Square Error(SSE)
% ---------------------------------------------------------------------------
% -----------Simulation Setup----------------------------------------------
A=10; %Amplitude
Phi=pi/4; %Phase
f=0.3; %Frequency
T=10; %Time-period
N=1000; %No. of samples
Var=100; %Variance
w=2*pi*f; %Angular Frequency
Itr=2000; %No. of Iterations
%-----------------------------------------------------------------------------
%---------- Generation of true signal and Gussian Noise Addition to true signal--------------------------------------
t= 0:T/N:T;
St= A*cos(w*t-Phi); %True Signal
Nt= sqrt(Var)*randn(size(t)); %Gussian Noise
Xt=St+Nt; %Adding Noise to True Signal to obtain Noisy Signal
% ---------------------------------------------------------------------------------------------------------
% -----------------Plot of True Signal And Noisy Signal--------------------
plot(t,St,'k'),hold on,plot(t,Xt,'k--'),legend('True Signal','Noisy Signal');
xlabel('Time'),ylabel('Amplitude');
title('True Signal And Noisy Signal');
% -----------------------------------------------------------------------------------------------------
% -------------Mean Estimate for True Signal and Plot for Estimated true signal-------------------------------
for i=1:Itr
Nt=sqrt(Var)*randn(size(t));
Xt(i,:)=St+Nt;
% [his ax]=hist(Xt,20);
% [maxVal,maxInd]=max(his);
% % [maxVal,high]=max(hist(Xt,t));
% % low=ax(maxInd)-T/(2*N);
% low=ax(maxInd)-(3.3577);
% high=ax(maxInd)+(3.3577);
% % high=ax(maxInd)+T/(2*N);
% F1=maxVal;
% if maxInd ~= 1
% F0=his(maxInd-1);
% else
% F0=0;
% end
% F2=his(maxInd+1);
% z=low+((F1-F0)'.*(high-low))./(2.*F1-F0-F2)';
%
% SSE(i)=sum((z'-St).^2);
%
end
for j=1:1001
[his ax]=hist(Xt(:,j),20);
[maxVal,maxInd]=max(his);
% [maxVal,high]=max(hist(Xt,t));
% low=ax(maxInd)-T/(2*N);
low=ax(maxInd)-(3.3577);
high=ax(maxInd)+(3.3577);
% high=ax(maxInd)+T/(2*N);
F1=maxVal;
if maxInd ~= 1
F0=his(maxInd-1);
else
F0=0;
end
F2=his(maxInd+1);
z(j)=low+((F1-F0)'.*(high-low))./(2.*F1-F0-F2)';
SSE(j)=sum((z(j)-St(j)).^2);
end
SSE_N=sum(SSE)
figure;
plot(t,z,'k'),hold on,plot(t,St,'r--');
xlabel('Time');
ylabel('Amplitude');
legend('Estimated True Signal','Known True Signal');
title('True aand Estimated Signal');
% -------------------------------------------------------------------------
% ----------------Plot for Noisy Signal and Noise--------------------------
figure;
plot(t,Xt(2,:),'k--')
% hold on;
% plot(t,Xt(20,:),'r')
hold on;
plot(t,Nt,'y')
% hold on;
% plot(t,Nt(20,:),'g')
legend('noisy1','noise1');
% ----------------------------------------------------------------------------------
% ---------------Calculation of SSE and Plot for SSE vs No of observations----------------------------------------
%
% figure;
% plot(1:Itr,SSE);
% title('SSE vs No of Observations');
% xlabel('No. of observations');
% ylabel('SSE');
JonSco
- 粉丝: 91
- 资源: 1万+
最新资源
- 自动 wget 脚本用于下载并安装 PC 游戏所需的所有 .Net,VC++ 可再发行组件 + 一些其他工具(如 7zip、Powershell 等) 焦土红色政策 .zip
- 自动化连线工具使用教程
- ES7210-userGuide-REV1-0.pdf ES7210用户指南 ES7210规格书寄存器版
- 简单的包装器,用于从 .NET 应用程序渲染 hrtf DirectX,Xaudio2 声音.zip
- 简单的 dll 将提供一些信息来帮助在应用程序中挂接 directx shitcode.zip
- 简单的 DirectX 11 游戏引擎.zip
- 基于ASP.NET+SqlServer 实现的简单教学管理系统课程设计
- python进阶-04课程源码
- 简单的 DirectX 11 Hello World.zip
- curl的so库以及头文件
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈