Index exceeds the number of array elements (1).

조회 수: 1 (최근 30일)
LaChelle McMahan
LaChelle McMahan 2020년 12월 12일
댓글: SHIVAM KUMAR 2020년 12월 12일
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
SHIVAM KUMAR 2020년 12월 12일
Telling the line number where this error occurs will make it easier to debug.
LaChelle McMahan
LaChelle McMahan 2020년 12월 12일
Pgj(a+1) =((Pj*Gj)/(4*p(Rj)^2))*((Lamda^2*Graj)/(4*p))*(1/Lr)*(BBW/(2*SSBW));
This is the line that produces the error.

댓글을 달려면 로그인하십시오.

채택된 답변

SHIVAM KUMAR
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');
  댓글 수: 2
LaChelle McMahan
LaChelle McMahan 2020년 12월 12일
Thanks!
SHIVAM KUMAR
SHIVAM KUMAR 2020년 12월 12일
I hope this is correct

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

SHIVAM KUMAR
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
SHIVAM KUMAR
SHIVAM KUMAR 2020년 12월 12일
which line is the error coming in ?
LaChelle McMahan
LaChelle McMahan 2020년 12월 12일
Pgj =((Pj*Gj)/(4*p*(Rj).^2))*((Lamda^2*Graj)/(4*p))*(1/Lr)*(BBW/(2*SSBW));
This line is causing the error.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by