why the plot doesn't work ,in the code i'm finding the estimation value of the phase using montecarlo simulation
2 次查看(过去 30 天)
显示 更早的评论
%phase astimation using monte carlo
clear all
close all
clc
%signal model x(n)=Acos(2pif0n+thetha)+w(n)
phase=0.75;
A=1;
sigma=0.1;
f0=0.035;
SNR=A^2/2*(sigma^2)
for m=1:length(SNR)
M=5;
for i=1:M;
s=A*cos(2*pi*f0*i+phase);
w=randn(size(s));
x(i)=s+sigma*w
y1=sum(x*sin(2*pi*f0*i))
y2=sum(x*cos(2*pi*f0*i))
phasehat(i)=-atan(y1+y2)
%
% mat(i,:)=phasehat
end
%compute bias
b(m)=(1/M)*sum(mean(phasehat(i))-phase)
%mean square error
mse=mean((phasehat(i)-phase)^2)
var=1/M*SNR
end
figure(1)
plot(10*log(SNR),b)
figure(2)
plot(10*log(SNR),mse)
figure(3)
plot(10*log(SNR),10*log(var))
0 个评论
回答(1 个)
Chris
2022-1-21
编辑:Chris
2022-1-21
since length(SNR) is 1, you are running one loop iteration and generating one point. plot() doesn't show one point unless you specify a marker:
figure(1)
plot(10*log(SNR),b,'o')
figure(2)
plot(10*log(SNR),mse,'x')
figure(3)
plot(10*log(SNR),10*log(var),'^')
or equivalently, use scatter:
figure(1)
scatter(10*log(SNR),b)
% ...etc
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Graphics Performance 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!