DEPARTMENT OF ELECTRONICS AND
TELECOMMUNICATION
An Experiential Learning Report
Principles of Electromagnetics
REPORT ON
“Solving numerical problems using MATLAB”
Submitted by:
Name: USN:
Raghavendra Sherkhane 1RV22ET037
Under the guidance of
Dr. Shambulinga M
Assistant Professor
Dept. of Electronics and Telecommunication.,
RV College of Engineering® Bengaluru-560059
In partial fulfillment of the requirements for the course of Bachelor
of
Engineering in ELECTRONICS AND TELECOMMUNICATION
2023-2024
Dept. of ETE RVCE 1
Table of Contents
1. Problem 1
a. Problem statement
b. Manual solution and visualisation
c. Matlab code to solve the problem
d. Matlab Results
2. Problem 2
a. Problem statement
b. Manual solution and visualisation
c. Matlab code to solve the problem
d. Matlab Results
Dept. of ETE RVCE 2
PROBLEM 1
1a. Problem statement:
Given the electric flux density D=5r2 ar mC/m2 for r ≤ 0.08 m
i): Find the divergence of D at r=0.06m.
ii): Calculate the total charge enclosed within the radius r=0.08
1b. Manual solution with visualization
Visual
Dept. of ETE RVCE 3
1c. Matlab code to solve the problem
% Constants
r_max = 0.08; % maximum radius for charge calculation (m)
r_values = linspace(0, r_max, 1000);
% Divergence of D
D_r = @(r) 5 * r.^2; % Use .^ for element-wise power
% Modify to ensure the arrays have compatible sizes
div_D = @(r) (1./r(2:end).^2) .* (diff(D_r(r) .* r.^2) ./ diff(r));
% Calculate divergence at r = 0.06 m
r_target = 0.06; % radius at which to compute divergence (m)
div_D_value = div_D(r_values);
div_D_at_06 = interp1(r_values(2:end), div_D_value, r_target);
% Total charge enclosed
q_enclosed = 4 * pi * trapz(r_values(2:end), r_values(2:end).^2 .* div_D_value);
Dept. of ETE RVCE 4
% Display the results
fprintf('Divergence of D at r = 0.06 m is %.4e C/m^3\n', div_D_at_06);
fprintf('Total charge enclosed is %.4e C\n', q_enclosed);
% Plotting
figure;
subplot(2,1,1);
plot(r_values(2:end), div_D_value, 'LineWidth', 2);
xlabel('Radius r (m)');
ylabel('Divergence of D (C/m^3)');
title('Divergence of D as a function of r');
grid on;
subplot(2,1,2);
plot(r_values(2:end), cumtrapz(r_values(2:end), r_values(2:end).^2 .* div_D_value), 'LineWidth', 2);
xlabel('Radius r (m)');
ylabel('Charge Enclosed Q (C)');
title('Total Charge Enclosed as a function of r');
grid on;
1d. Matlab Results
Dept. of ETE RVCE 5
PROBLEM 2
2a. Problem statement
What is the magnetic field intensity vector H between two parallel sheets with
separation t along z axis both carrying surface current K=Ky ŷ A/m
2b. Manual solution with visualization
Type your manual calculation here
Visual
Dept. of ETE RVCE 6
2c. Matlab code to solve the problem
% Parameters
K_y = 1; % Surface current density in A/m (assuming K_y = 1 for simplicity)
t = 0.1; % Separation between the sheets along the z-axis (in meters)
% Define the z-axis range
z = linspace(-0.2, 0.3, 1000); % Extend beyond the sheets to see the effect outside
% Magnetic field intensity H
H_x = zeros(size(z)); % Initialize the H_x array
% Compute H_x in different regions
for i = 1:length(z)
if z(i) < 0
H_x(i) = 0; % No magnetic field below the first sheet
elseif z(i) <= t
H_x(i) = K_y; % Magnetic field between the sheets
else
H_x(i) = 0; % No magnetic field above the second sheet
end
end
% Plotting the magnetic field intensity
figure;
plot(z, H_x, 'LineWidth', 2);
xlabel('z (m)');
ylabel('H_x (A/m)');
title('Magnetic Field Intensity H_x as a function of z');
grid on;
xline(0, '--r', 'Sheet 1');
xline(t, '--r', 'Sheet 2');
ylim([-0.5 1.5]); % Set limits to better visualize the field
legend('H_x', 'Sheet 1', 'Sheet 2');
2d. Matlab results
Dept. of ETE RVCE 7