0% found this document useful (0 votes)
17 views2 pages

Electric Circuit - Differential Equations - Ex - 1

The document presents state-variable equations for a circuit model and outlines a MATLAB solution to plot the responses of state variables VC, IL, and output Vo for different input voltage waveforms (square, sawtooth, and sine) over a time span of 50 seconds. It includes initial conditions, time span setup, and the use of the ode45 function to solve the equations. The results are visualized in multiple figures showing the behavior of the circuit under various input conditions.

Uploaded by

Mazin Alsaedi
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)
17 views2 pages

Electric Circuit - Differential Equations - Ex - 1

The document presents state-variable equations for a circuit model and outlines a MATLAB solution to plot the responses of state variables VC, IL, and output Vo for different input voltage waveforms (square, sawtooth, and sine) over a time span of 50 seconds. It includes initial conditions, time span setup, and the use of the ode45 function to solve the equations. The results are visualized in multiple figures showing the behavior of the circuit under various input conditions.

Uploaded by

Mazin Alsaedi
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
You are on page 1/ 2

Q- The state-variable equations for

the circuit model shown in the figure


are:

VC  3I L  6VC  2Vin (t )


1
10

IL   2 I L  3VC  Vin (t )


2
5
where the output voltage is:

Vo 
1
 I L  3VC  Vin (t )
5

Plot the desire response the state variables: VC , I L , and the output Vo for each of the three cases of input voltages
with an amplitude (1 volt) and frequency ( Hz): square wave , saw tooth wave, and sine wave. (0⩽ t ⩽50 sec)

--------------------------------------------------------- MATLAB solution -------------------------------------------------------

% Dr. Mazin Ismael , 14-Nov-2024


% initial values for the circuit, for example
x1_0 = 0; % Vc(0)
x2_0 = 0; % IL(0)
x0 = [x1_0 x2_0];

tspan=0:(50/1000):50; % dividing the time span 50 to 1000 step

[t,x] = ode45('electricity_System_1',tspan,x0);

Amp = 1; % Amplitude of input/output


fs = 0.05; % Hz
Vin = Amp * square(2*pi*fs*t,50); % 50 = 50% ( duty cycle : 0 ~ 100)
% fs = 0.065; % Hz. used for sawtooth and sine inputs
% Vin = Amp * sawtooth(2*pi*fs*t);
% Vin = Amp * sin(2*pi*fs*t);

Vo = (1/5) * ( + Vin) ; % Algebric equation

figure (1)
subplot(4,1,1),plot(t,Vin,'r');
grid on
ylim([-(Amp+.2) (Amp+.2)]) %
xlabel('time [sec]'); ylabel('Vin [Volt]');
subplot(4,1,2),plot(t,x(:,1),'b');
grid on
xlabel('time [sec]'); ylabel('Vc [Volt]');
subplot(4,1,3),plot(t,x(:,2),'Color',[0.47,0.67,0.19]);
grid on
xlabel('time [sec]'); ylabel('IL [Amp]');
subplot(4,1,4),plot(t,Vo,'k');
grid on;
xlabel('time [sec]'); ylabel('Vo [Volt]');
function dx = electricity_System_1(t,x)

Amp = 1; % Amplitude of input/output


fs = 0.05; % Hz
Vin = Amp * square(2*pi*fs*t,50); % 50 = 50% ( duty cycle : 0 ~ 100)

% fs = 0.065; % Hz for sawtooth and sine inputs


% Vin = Amp * sawtooth(2*pi*fs*t);
% Vin = Amp * sin(2*pi*fs*t);

dx(1) = (1/10) * (3*x(2) - 6*x(1) + 2* Vin) ; % Vc dot


dx(2) = (2/5) * (-2*x(2) - 3*x(1) + Vin) ; % IL dot

dx = dx(:); % into column vector

------------------------------------------------------------- End ----------------------------------------------------------

Figure (a): results for square wave input

Figure (b): results for saw tooth wave input Figure (c): results for sine wave input

You might also like