EEE282
Section:04 Group No:02
Project Report
Prepared by:
Name: MD. Mahfuzur Rahman ID: 24121375 Signature
All Group members:
Sl. Name ID Signature
1. MD. Mahfuzur Rahman 24121375
2. S M Rafsan Sajid 24121216
3. Nasif Mahbub 24121149
4. Faheem Islam Dip 24121069
Date of Submission: 10/9/2025
Solution of Question No-1
(a) Numerical Technique for Error Correction
The student needs to estimate the voltage values at intermediate time points (t =
0.125, 0.375, 0.625, 0.875 ms) that were not sampled due to the incorrect sampling time.
To correct this error, the appropriate numerical technique is Lagrange Interpolation.
Why Lagrange Interpolation?
• The student has discrete data points at unequal intervals that need to be connected
smoothly
• Lagrange interpolation provides an exact polynomial that passes through all given data
points
• It is suitable for reconstructing a continuous signal from limited samples
• The method is straightforward to implement for a small number of data points (5 points
in this case)
• It provides a mathematical function v(t) that can be evaluated at any desired time
(b) Numerical Implementation and Results
The Lagrange interpolation formula is given by:
n n
X Y t − Tj
v(t) = Vi ·
i=1
T − Tj
j=1 i
j̸=i
where n = 5 data points, Ti are the time values, and Vi are the corresponding voltage
values.
MATLAB Implementation
The following MATLAB code implements Lagrange interpolation to estimate the missing
voltage values:
clc ; clear all ; close all ;
% Given data from Table -1
T = [0:0.25:1];
V = [0 2.696 3.939 4.511 4.775];
n = length ( T ) ;
t = 0:0.125:1;
v_lagrange = zeros ( size ( t ) ) ;
% Lagrange interpolation computation
for k = 1: length ( t )
sum_val = 0;
1
for i = 1: n
prod_val = 1;
for j = 1: n
if i ~= j
prod_val = prod_val * (( t ( k ) -T ( j ) ) /( T ( i ) -T ( j ) ) ) ;
end
end
sum_val = sum_val + prod_val * V ( i ) ;
end
v_lagrange ( k ) = sum_val ;
end
% Display required interpolated values
fprintf ( ’ Interpolated values using Lagrange interpolation :\ n ’) ;
required_indices = [2 , 4 , 6 , 8];
for i = required_indices
fprintf ( ’t = %.3 f ms = > v = %.3 f volts \ n ’ , t ( i ) , v_lagrange ( i
));
end
% Plotting results
figure ;
plot (T , V , ’ yo ’ , ’ MarkerSize ’ , 10 , ’ LineWidth ’ , 2 , ’
MarkerFaceColor ’ , ’k ’) ;
hold on ;
plot ( t ( required_indices ) , v_lagrange ( required_indices ) , ’ ro ’ , ’
MarkerSize ’ , 8 , ’ LineWidth ’ , 2 , ’ MarkerFaceColor ’ , ’k ’) ;
plot (t , v_lagrange , ’c - ’ , ’ LineWidth ’ , 1.5) ;
xlabel ( ’ Time ( ms ) ’) ; ylabel ( ’ Voltage ( volts ) ’) ;
legend ( ’ Given Data ’ , ’ Interpolated Points ’ , ’ Lagrange Polynomial ’
);
title ( ’ Lagrange Interpolation of Voice Signal ’) ;
grid on ;
set ( gca , ’ Color ’ , ’k ’ , ’ GridColor ’ , ’w ’ , ’ XColor ’ , ’w ’ , ’ YColor ’ ,
’w ’) ;
Output Results
The code produces the following interpolated values:
Interpolated values using Lagrange interpolation:
t = 0.125 ms => v = 1.595 volts
t = 0.375 ms => v = 3.440 volts
t = 0.625 ms => v = 4.276 volts
t = 0.875 ms => v = 4.675 volts
2
Simulation Plot
Complete Data Table
The completed data table with all sampled and interpolated values is:
Table 1: Complete Voltage Data with Interpolated Values
t (ms) 0 0.125 0.25 0.375 0.5 0.625 0.75 0.875 1
v (volts) 0 1.636 2.696 3.469 3.939 4.317 4.511 4.699 4.775
The student can now use this complete dataset with the correct sampling interval of
Ts = 0.125 ms for perfect signal reconstruction according to Nyquist’s theorem.
3
Question2:
solving (i)
clc;
clear all;
close all;
T=0:0.125:1;
V=[0 1.595 2.828 3.440 4.000 4.276 4.500 4.675 4.750];
V_squared=V.^2;
I=trapz(T,V_squared);
Vrms=sqrt(I/(T(end)-T(1)));
true_val=3.6908;
abs_error=abs(Vrms-true_val);
pct_error=abs_error/true_val*100;
fprintf('COMPUTED RMS VOLTAGE=%.6f V\n',Vrms);
fprintf('TRUE RMS VOLTAGE=%.4f V\n',true_val);
fprintf('ABSOLUTE ERROR=%.6f V\n',abs_error);
fprintf('PERCENTAGE ERROR=%.4f %%\n',pct_error);
Solving (ii)
clc;
clear all;
close all;
p=[-3.5694 19.0546 -30.88 20.133 -3.4412];
v=@(t) polyval(p, t);
v_sq=@(t) (v(t)).^2;
t1=0;
t2=1;
I=integral(v_sq,t1,t2);
Vrms=sqrt(I/(t2-t1));
V_true=3.6908;
err_abs=abs(Vrms-V_true);
err_pct=(err_abs/V_true)*100;
fprintf('RMS Voltage(from polynomial)=%.6f V\n',Vrms);
fprintf('True RMS Voltage=%.4f V\n',V_true);
fprintf('Absolute Error=%.6f V\n',err_abs);
fprintf('Percentage Error=%.4f %%\n',err_pct);
t=linspace(t1,t2,200);
plot(t,v(t),'b-','LineWidth',2);
hold on;
scatter([0 0.25 0.5 0.75 1],v([0 0.25 0.5 0.75 1]),60,'r','filled');
xlabel('Time (s)');ylabel('Voltage (V)');
title('Voltage Signal v(t)');
legend('v(t)','Sample Points');
grid on;
plot(t, v_sq(t),'m-','LineWidth', 2);
xlabel('Time (s)'); ylabel('v^2 (V^2)');
title('Squared Voltage v^2(t)');
grid on;
Question3:
Solution to the question no .3
SM Rafsan Sajid ; 24121216 ; G2
● (i) Applicability of Numerical Differentiation Approaches
● To determine the current through the capacitor, we need the derivative of voltage with respect to
time
● Since we only have sampled voltage data (Table-2), the derivative must be approximated using
Numerical Differentiation methods.
○ Forward Difference:
Used at the first data point because no previous value exists. It uses the next value to
estimate slope
○ Backward Difference:
Used at the last data point because no next value exists. It uses the previous value
○ Central Difference:
Applied at all interior points for better accuracy, since it uses both forward and backward
values:
Thus, all three approaches are applicable depending on the position of the data point
(start, end, or middle).
●
● (ii) Determination of Current and Comparison
● For each sampled time instant, the current is calculated
● where C=10μFC
Using the numerical differentiation methods described in part (i), the approximated current is
obtained from the voltage data (Table-2).
● Finally, the approximated current values are compared with the true current values (Table-3).
The comparison is shown graphically, where both currents are plotted on the same figure. This
allows us to evaluate the accuracy of the numerical differentiation method.
From q1 ,
Matlab code for solving (i) and (ii) :
clc;
clear all;
close all;
C = 10e-6; % 10 micro Farad
t = [0 0.125 0.25 0.375 0.5 0.625 0.75 0.875 1];
t = t * 1e-3; % seconds
Vc = [0 1.636 2.696 3.469 3.939 4.317 4.511 4.699 4.775];
n = length(t);
Ic_approx = zeros(1,n);
%(i)Numerical differentiation
for i =1:n
if i ==1
dVdt =(Vc(i+1)-Vc(i)) / (t(i+1)-t(i)); %Forward difference
elseif i== n
dVdt = (Vc(i)-Vc(i-1)) / (t(i)-t(i-1)); %Backward difference
else
dVdt= (Vc(i+1)-Vc(i-1)) / (t(i+1)-t(i-1)); %Central difference
end
Ic_approx(i) = C* dVdt;
end
%(ii)Comparison with True Current
Ici_true = [155 105.207 71.409 48.469 32.898 22.330 15.156 10.287 6.983];
Ici_true = Ici_true * 1e-3; % convert mA to A
figure;
plot(t*1e3,Ici_true*1e3,'r-o','LineWidth',2); hold on;
plot(t*1e3, Ic_approx*1e3,'b-o','LineWidth',2);
xlabel('Time (ms)');
ylabel('Current (mA)');
title('True Current vs Approximated Current');
legend('True Current (Table-3)','Approximated Current (from Table-2)');
grid on;
Plotted the true current (Table – 3) and approximated current :
Question4:
Code:
clc;
clear;
close all;
function time()
fprintf('Using equation: V(t)= -4.469 + 15.045t - 20.953t² + 15.152t³\n');
voltage_func= @(t) -4.469 + 15.045*t - 20.953*t.^2 + 15.152*t.^3;
target_voltage= 4.0;
root_func= @(t) voltage_func(t)-target_voltage;
for t= 0:0.1:1.5
v= voltage_func(t);
fprintf('%.1f\t\t%.3f\n',t,v);
end
a=0.4;
b=0.6;
tolerance=1e-6;
max_iterations=100;
if root_func(a)*root_func(b)>=0
[a,b]=find_bracket(root_func,0,1);
end
% Bisection
iteration=0;
while (b-a) > tolerance && iteration < max_iterations
iteration=iteration+1;
c=(a+b)/2;
f_c=root_func(c);
fprintf('Iteration %2d: t=%.6f, V(t)=%.6f\n', iteration, c, voltage_func(c));
if root_func(a)*f_c < 0
b=c;
else
a=c;
end
end
% Final result
crossing_time=(a+b)/2;
final_voltage=voltage_func(crossing_time);
fprintf('RESULT\n');
fprintf('Voltage crosses 4.0V at t = %.6f seconds\n',crossing_time);
fprintf('V(%.6f) = %.6f V\n',crossing_time,final_voltage);
% Plot
plot_voltage_curve(voltage_func,crossing_time,target_voltage);
end
function [a,b] = find_bracket(func,start,max_time)
step=0.01;
a=start;
for t=start:step:max_time
if func(t)*func(t+step)<=0
a=t;
b=t+step;
return;
end
end
a=0.4;
b=0.6;
end
function plot_voltage_curve(voltage_func, crossing_time, target_voltage)
t=linspace(0, 1, 1000);
v=voltage_func(t);
figure;
hold on;
grid on;
plot(t, v, 'b-', 'LineWidth', 2, 'DisplayName', 'V(t) = -4.469 + 15.045t - 20.953t² +
15.152t³');
plot([0, 1], [target_voltage, target_voltage], 'r--', 'LineWidth', 1.5, 'DisplayName',
'4.0V threshold');
plot(crossing_time, target_voltage, 'go', 'MarkerFaceColor', 'g', 'DisplayName',
sprintf('Crossing point: t=%.4fs', crossing_time));
xlabel('Time (seconds)');
ylabel('Voltage (V)');
title('Voltage vs Time - Finding when V(t) crosses 4.0V');
legend();
xlim([0, 1]);
ylim([-5, 10]);
end
% Run the main function
time();
Pic: