How to find the RMSE? Reposted @torsten
@Torsten
I asked this question on URL: https://www.mathworks.com/matlabcentral/answers/2172760-how-to-find-the-rmse
Even I responded there several times but then I became busy and when I got free to respond there, my response was not recorded. I tried sevral times but in vain. That’s why I am re-posting here.
I used the "rmse code" with my previous code (just added awgn() to add noise ) but it gives me error:
clear;clc
ula = phased.ULA(‘NumElements’,10,’ElementSpacing’,0.5);
angs = [40 -20 20; 0 0 0];% angs=[azimuth; elevation]; My desired angles are 40, -20 and 20.
NumSignals = size(angs,2);
c = physconst(‘LightSpeed’);
fc = 300e6; % Operating frequency
lambda = c/fc;
pos = getElementPosition(ula)/lambda;
Nsamp = 10;%1000;
nPower = 0.01;
rs = rng(2007);
signal = sensorsig(pos,Nsamp,angs,nPower);
signal = awgn(signal,-15);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% MUSIC Algorithm
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
musicspatialspect = phased.MUSICEstimator(‘SensorArray’,ula,…
‘OperatingFrequency’,fc,’ScanAngles’,-90:90,…
‘DOAOutputPort’,true,’NumSignalsSource’,’Property’,’NumSignals’,NumSignals);
[~,ang] = musicspatialspect(signal)
ymusic = musicspatialspect(signal);
helperPlotDOASpectra(musicspatialspect.ScanAngles,ymusic)% Changed by Me
function helperPlotDOASpectra(x2,y2)% Changed by Me
% Plot spectra in dB normalized to 0 dB at the peak
y2_dB = 20*log10(y2) – max(20*log10(y2));
plot(x2,y2_dB)
xlabel(‘Broadside Angle (degrees)’);
ylabel(‘Power (dB)’);
title(‘DOA Spatial Spectra’)
end
%%%%%%% RMSE
num_runs = 100;
rmse_values = zeros(1, num_runs);
for idx = 1:num_runs
error = angs – ang;
rmse = sqrt(mean(error.^2));
rmse_values(idx) = rmse;
end
figure;
plot(1:num_runs, rmse_values, ‘-o’);
xlabel(‘Run Number’);
ylabel(‘RMSE’);
title(‘RMSE vs Number of Runs’);
grid on;@Torsten
I asked this question on URL: https://www.mathworks.com/matlabcentral/answers/2172760-how-to-find-the-rmse
Even I responded there several times but then I became busy and when I got free to respond there, my response was not recorded. I tried sevral times but in vain. That’s why I am re-posting here.
I used the "rmse code" with my previous code (just added awgn() to add noise ) but it gives me error:
clear;clc
ula = phased.ULA(‘NumElements’,10,’ElementSpacing’,0.5);
angs = [40 -20 20; 0 0 0];% angs=[azimuth; elevation]; My desired angles are 40, -20 and 20.
NumSignals = size(angs,2);
c = physconst(‘LightSpeed’);
fc = 300e6; % Operating frequency
lambda = c/fc;
pos = getElementPosition(ula)/lambda;
Nsamp = 10;%1000;
nPower = 0.01;
rs = rng(2007);
signal = sensorsig(pos,Nsamp,angs,nPower);
signal = awgn(signal,-15);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% MUSIC Algorithm
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
musicspatialspect = phased.MUSICEstimator(‘SensorArray’,ula,…
‘OperatingFrequency’,fc,’ScanAngles’,-90:90,…
‘DOAOutputPort’,true,’NumSignalsSource’,’Property’,’NumSignals’,NumSignals);
[~,ang] = musicspatialspect(signal)
ymusic = musicspatialspect(signal);
helperPlotDOASpectra(musicspatialspect.ScanAngles,ymusic)% Changed by Me
function helperPlotDOASpectra(x2,y2)% Changed by Me
% Plot spectra in dB normalized to 0 dB at the peak
y2_dB = 20*log10(y2) – max(20*log10(y2));
plot(x2,y2_dB)
xlabel(‘Broadside Angle (degrees)’);
ylabel(‘Power (dB)’);
title(‘DOA Spatial Spectra’)
end
%%%%%%% RMSE
num_runs = 100;
rmse_values = zeros(1, num_runs);
for idx = 1:num_runs
error = angs – ang;
rmse = sqrt(mean(error.^2));
rmse_values(idx) = rmse;
end
figure;
plot(1:num_runs, rmse_values, ‘-o’);
xlabel(‘Run Number’);
ylabel(‘RMSE’);
title(‘RMSE vs Number of Runs’);
grid on; @Torsten
I asked this question on URL: https://www.mathworks.com/matlabcentral/answers/2172760-how-to-find-the-rmse
Even I responded there several times but then I became busy and when I got free to respond there, my response was not recorded. I tried sevral times but in vain. That’s why I am re-posting here.
I used the "rmse code" with my previous code (just added awgn() to add noise ) but it gives me error:
clear;clc
ula = phased.ULA(‘NumElements’,10,’ElementSpacing’,0.5);
angs = [40 -20 20; 0 0 0];% angs=[azimuth; elevation]; My desired angles are 40, -20 and 20.
NumSignals = size(angs,2);
c = physconst(‘LightSpeed’);
fc = 300e6; % Operating frequency
lambda = c/fc;
pos = getElementPosition(ula)/lambda;
Nsamp = 10;%1000;
nPower = 0.01;
rs = rng(2007);
signal = sensorsig(pos,Nsamp,angs,nPower);
signal = awgn(signal,-15);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% MUSIC Algorithm
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
musicspatialspect = phased.MUSICEstimator(‘SensorArray’,ula,…
‘OperatingFrequency’,fc,’ScanAngles’,-90:90,…
‘DOAOutputPort’,true,’NumSignalsSource’,’Property’,’NumSignals’,NumSignals);
[~,ang] = musicspatialspect(signal)
ymusic = musicspatialspect(signal);
helperPlotDOASpectra(musicspatialspect.ScanAngles,ymusic)% Changed by Me
function helperPlotDOASpectra(x2,y2)% Changed by Me
% Plot spectra in dB normalized to 0 dB at the peak
y2_dB = 20*log10(y2) – max(20*log10(y2));
plot(x2,y2_dB)
xlabel(‘Broadside Angle (degrees)’);
ylabel(‘Power (dB)’);
title(‘DOA Spatial Spectra’)
end
%%%%%%% RMSE
num_runs = 100;
rmse_values = zeros(1, num_runs);
for idx = 1:num_runs
error = angs – ang;
rmse = sqrt(mean(error.^2));
rmse_values(idx) = rmse;
end
figure;
plot(1:num_runs, rmse_values, ‘-o’);
xlabel(‘Run Number’);
ylabel(‘RMSE’);
title(‘RMSE vs Number of Runs’);
grid on; rmse, root mean square error, code error MATLAB Answers — New Questions