Index exceeds the number of array elements (1).
1 次查看(过去 30 天)
显示 更早的评论
clear all;
Rj=(1:1:30);
Pj= 1; %Power in Watts
Gj= 1; %Gain of antenna of jammer
c=3*10^8; %Speed of Light
f= 1575*10^9 ;
Lamda=c/f;
Graj= 0.5; %Gain of GPS receiver
BBW= 50; %Baswband Signal Bandwidth in Hz
Lr= 1.58; %Atmospheric losses
SSBW= 10230000; %Spead Spectrum Bandwidth in Hz
DZ= -162;
p=pi;
for a = length(Rj)
Pgj(a+1) =((Pj*Gj)/(4*p(Rj)^2))*((Lamda^2*Graj)/(4*p))*(1/Lr)*(BBW/(2*SSBW));
end
plot(Rj,10*log10(Pgj), Rj,DZ);
title({'GPS Jamming Power in dBW vs Range in km'});
ylabel('Power dBW');
xlabel('Range(km)');
legend('10*Log (Pgj)','Denial Zone = - 162dB');
Hello I keep getting this error. I'm not sure how to fix. Any guidance would be greatly appreciated.
2 个评论
SHIVAM KUMAR
2020-12-12
Telling the line number where this error occurs will make it easier to debug.
采纳的回答
SHIVAM KUMAR
2020-12-12
编辑:SHIVAM KUMAR
2020-12-12
I run it with adding 1 more dot before division . this runs and plots the graph though I am not sure if everything is working fine. And make DZ a array to plot that correctly.
In case its correct accept the answer and close this thing.
clear all;
Rj=(1:1:30);
Pj= 1; %Power in Watts
Gj= 1; %Gain of antenna of jammer
c=3*10^8; %Speed of Light
f= 1575*10^9 ;
Lamda=c/f;
Graj= 0.5; %Gain of GPS receiver
BBW= 50; %Baswband Signal Bandwidth in Hz
Lr= 1.58; %Atmospheric losses
SSBW= 10230000; %Spead Spectrum Bandwidth in Hz
DZ= -162.0*ones(1,30);
p=pi;
%remove the loop its not actually needed .
%I hope you used (Rj)^2 to square each of its elements and not the matrix so use a dot operator to make matlab do that
Pgj =((Pj*Gj)./(4*p*(Rj).^2))*((Lamda^2*Graj)/(4*p))*(1/Lr)*(BBW/(2*SSBW));
plot(Rj,10*log10(Pgj), Rj,DZ);
title({'GPS Jamming Power in dBW vs Range in km'});
ylabel('Power dBW');
xlabel('Range(km)');
legend('10*Log (Pgj)','Denial Zone = - 162dB');
更多回答(1 个)
SHIVAM KUMAR
2020-12-12
编辑:SHIVAM KUMAR
2020-12-12
What I guessed it you didn't use the loop properly
clear all;
Rj=(1:1:30);
Pj= 1; %Power in Watts
Gj= 1; %Gain of antenna of jammer
c=3*10^8; %Speed of Light
f= 1575*10^9 ;
Lamda=c/f;
Graj= 0.5; %Gain of GPS receiver
BBW= 50; %Baswband Signal Bandwidth in Hz
Lr= 1.58; %Atmospheric losses
SSBW= 10230000; %Spead Spectrum Bandwidth in Hz
DZ= -162;
p=pi;
%remove the loop its not actually needed .
%I hope you used (Rj)^2 to square each of its elements and not the matrix so use a dot operator to make matlab do that
Pgj =((Pj*Gj)/(4*p*(Rj).^2))*((Lamda^2*Graj)/(4*p))*(1/Lr)*(BBW/(2*SSBW));
plot(Rj,10*log10(Pgj), Rj,DZ);
title({'GPS Jamming Power in dBW vs Range in km'});
ylabel('Power dBW');
xlabel('Range(km)');
legend('10*Log (Pgj)','Denial Zone = - 162dB');
4 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!