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 Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by