Index exceeds the number of array elements (1).
Show older comments
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 Comments
SHIVAM KUMAR
on 12 Dec 2020
Telling the line number where this error occurs will make it easier to debug.
LaChelle McMahan
on 12 Dec 2020
Accepted Answer
More Answers (1)
SHIVAM KUMAR
on 12 Dec 2020
Edited: SHIVAM KUMAR
on 12 Dec 2020
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 Comments
SHIVAM KUMAR
on 12 Dec 2020
Matlab does array computations even without loop.
LaChelle McMahan
on 12 Dec 2020
SHIVAM KUMAR
on 12 Dec 2020
which line is the error coming in ?
LaChelle McMahan
on 12 Dec 2020
Categories
Find more on Matched Filter and Ambiguity Function in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!