Difficulty getting power on an Airplane Radar project
1 view (last 30 days)
Show older comments
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 Comments
Answers (1)
Sai Kiran
on 19 Oct 2022
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 Comments
See Also
Categories
Find more on Radar and EW Systems 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!