Difficulty getting power on an Airplane Radar project
조회 수: 1 (최근 30일)
이전 댓글 표시
I've got an issue with a matlab code I'm writing. I am attempting to plot the variable t, which is time, against the power variable. The issue is that matlab doesn't create an array for time that is matching the array for Gain. It seems to me that this is why the division for power isn't sucessful. Ive included the full code below in. I would appreciate any help that could be given!
clc; clear; close all;
N = 20; % Number of elements
M = 50; % IDK
Bd = pi/4; % Beta*distance between elements
phi = linspace(0,2*pi,300); % also dont exactly know
for i = 1:M
%% Power Pattern
alpha = 8*Bd*i/M; % Might have to change
psi = (Bd * cos(phi)) + (alpha);
F_array = (abs(sin(N*psi/2)./sin(psi/2))).^2; % Power radiation pattern
F_array_max = 400; % N^2
Pn = F_array / F_array_max; % Normalized power radiation pattern; max value 1
subplot(2,2,1)
polarplot(phi,Pn);
rlim([0 1])
%% Airplane Travel
t = 0:1:i; % makes t a function of time
z = (5000 - (t*(100))); % distance to airplane with time
theta = asin(500./z); % angle to airplane with time
subplot(2,2,2)
polarplot(theta,z);
%% Airplane Power Recieved
D = 1.64*( (cos(90*cos(psi))) / (((sin(psi))).^2));
Gain = (D * F_array).^2;
r = sqrt(250000 + z.^2);
Power = Gain / (r.^4);
subplot(2,2,3)
plot(t, Gain,'*')
pause(.5)
end;
댓글 수: 3
답변 (1개)
Sai Kiran
2022년 10월 19일
Hi,
The error is caused due to mismatch between dimensions of Gain(1x300) and r (1x2) .
Variable r is dependent on t and whereas t =0:1:i which is dependent on iterable variable i . This changes the dimension of t in every iteration.
Try to keep the dimension of t constant and equal to that of Gain. Then the code runs without throwing any error.
Hope it helps!
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Radar and EW Systems에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!