0% found this document useful (0 votes)
7 views3 pages

Write C

The document contains MATLAB code snippets for various simulations, including the normalized radiation pattern of a helical antenna, beamforming in a uniform linear array, a two-body simulation of the Earth and Moon, and an orthogonal mode transducer (OMT) simulation. Each section includes code for generating plots that visualize the results of the simulations. The simulations cover topics in antenna theory, signal processing, orbital mechanics, and communication systems.

Uploaded by

albertmax111s
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views3 pages

Write C

The document contains MATLAB code snippets for various simulations, including the normalized radiation pattern of a helical antenna, beamforming in a uniform linear array, a two-body simulation of the Earth and Moon, and an orthogonal mode transducer (OMT) simulation. Each section includes code for generating plots that visualize the results of the simulations. The simulations cover topics in antenna theory, signal processing, orbital mechanics, and communication systems.

Uploaded by

albertmax111s
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

1...

% Normalized Radiation Pattern of Helical Antenna


clc;
clear;
N = 5;
lambda = 0.2;
C = lambda;
alpha = 12;
k = 2 * pi / lambda;
theta = linspace(0, pi, 1000); % 0 to 180 degrees
theta_deg = theta * 180 / pi;
psi = k * C * cos(theta) + deg2rad(alpha);
E_theta = sin(theta) .* (sin(N * psi / 2) ./ sin(psi / 2));
E_theta = abs(E_theta);
E_theta = E_theta / max(E_theta); % Normalize
figure;
polar(theta, E_theta);
title('Normalized Radiation Pattern of Helical Antenna (Classic Polar Plot)');

3..............
% Beamforming in Uniform Linear Array
clc;
clear;
N = 8;
d = 0.5;
theta_steer = 30;
theta = -90:0.1:90;
theta_rad = deg2rad(theta);
theta_steer_rad = deg2rad(theta_steer);
beta = 2 * pi * d * sin(theta_rad);
steer_vector = exp(1j*2*pi*d*(0:N-1)*sin(theta_steer_rad));
AF = zeros(size(theta_rad));
for k = 1:length(theta_rad)
a = exp(1j * 2 * pi * d * (0:N-1)' * sin(theta_rad(k)));
AF(k) = steer_vector * a;
end
AF = abs(AF);
AF = AF / max(AF);
AF_dB = 20 * log10(AF);
AF_dB(AF_dB < -40) = -40;
figure;
plot(theta, AF_dB, 'b', 'LineWidth', 2);
xlabel('Angle (degrees)');
ylabel('Normalized Gain (dB)');
title(['Beamforming Pattern towards ', num2str(theta_steer), '°']);
grid on;
axis([-90 90 -40 5]);
5...
% Two-body Simulation: Earth and Satellite/Moon
clc;
clear;
G = 6.67430e-11; % m^3/kg/s^2
M1 = 5.972e24;
M2 = 7.348e22;
r0 = [384400e3; 0];
v0 = [0; 1022];
dt = 100;
T = 27.3 * 24 * 3600;
N = round(T/dt);
r = zeros(2, N);
v = zeros(2, N);
r(:,1) = r0;
v(:,1) = v0;
for i = 1:N-1
r_norm = norm(r(:,i));
a = -G * (M1 + M2) * r(:,i) / r_norm^3;
v(:,i+1) = v(:,i) + a * dt;
r(:,i+1) = r(:,i) + v(:,i+1) * dt;
end
figure;
plot(r(1,:)/1e6, r(2,:)/1e6, 'b');
hold on;
plot(0, 0, 'ro', 'MarkerSize', 10, 'MarkerFaceColor', 'r');
xlabel('x (Mm)');
ylabel('y (Mm)');
title('Two-Body Simulation: Moon Orbiting Earth');
axis equal;
grid on;
7....

% OMT Simulation - Orthogonal Mode Transducer


clc;
clear;
t = linspace(0, 1, 1000);
f = 10e9;
H_pol = cos(2*pi*f*t);
V_pol = sin(2*pi*f*t);
input_signal = H_pol + 1j * V_pol;
OMT_matrix = [1, 0; 0, 1];
% Apply OMT to input signal (project onto orthogonal basis)
output_H = real(input_signal);
output_V = imag(input_signal);
figure;
subplot(3,1,1);
plot(t, real(input_signal));
title('Input Signal (Real Part - Horizontal)');
xlabel('Time (s)');
ylabel('Amplitude');
subplot(3,1,2);
plot(t, imag(input_signal));
title('Input Signal (Imag Part - Vertical)');
xlabel('Time (s)');
ylabel('Amplitude');
subplot(3,1,3);
plot(t, output_H, '-b', 'DisplayName', 'H-output'); hold on;
plot(t, output_V, '-r', 'DisplayName', 'V-output');
title('OMT Output: Separated Signals');
xlabel('Time (s)');
ylabel('Amplitude');
legend;
grid on;

You might also like