why the plot doesn't work ,in the code i'm finding the estimation value of the phase using montecarlo simulation
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
%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 Kommentare
Antworten (1)
Chris
am 21 Jan. 2022
Bearbeitet: Chris
am 21 Jan. 2022
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
4 Kommentare
Siehe auch
Kategorien
Mehr zu Graphics Performance finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!