-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathDrawOutputWaveforms.m
More file actions
48 lines (39 loc) · 2.43 KB
/
DrawOutputWaveforms.m
File metadata and controls
48 lines (39 loc) · 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
global C Signal h;
%C : The value of the capacitor
%Signal : Type of the input signal
%h : Time vector
if Signal==1 % If the input signal is a step wave
% The voltage waveform Vc(t)
axes(handles.axes3); % Draw the following in the axes 3
[t,y]=ode15s('RLCEqu',[0 1],[0 0]); % Solve the differential equation of the circuit
plot(t,y(:,1),'LineWidth',2,'Color','red'); % Draw the solution and change the width and the color of the line
set(handles.axes3,'Color',[0.306 0.396 0.58]) % Change the background color
legend('Voltage Vout(V)'); % show legend
axis auto; % automatic scales of the axis
grid on; % Enable the grid
%The current waveform i(t)
axes(handles.axes4); % Draw the following in the axes 4
plot(t,C*y(:,2),'LineWidth',2,'Color','red') % Dessiner le graphe
set(handles.axes4,'Color',[0.306 0.396 0.58]) % change backgroud
legend('Current I(A)'); % show legend
xlabel('Time(s)'); % x label
axis auto; % automatic scale of the axis
grid on % Enable the grid
else % If the input signal is triangle or sine wave
% The voltage waveform Vc(t)
axes(handles.axes3); % Draw the following in the axes 3
[t,y]=ode15s('RLCEqu',[0 20],[0 0]); % Solve the differential equation of the circuit
plot(t,y(:,1),'LineWidth',2,'Color','red'); % Draw the solution and change the width and the color of the line
set(handles.axes3,'Color',[0.306 0.396 0.58]) % Change the background color
legend('Voltage Vout(V)'); % show legend
axis auto; % automatic scales of the axis
grid on; % Enable the grid
%The current waveform i(t)
axes(handles.axes4); % Draw the following in the axes 4
plot(t,C*y(:,2),'LineWidth',2,'Color','red'); % Draw the solution and change the width and the color of the line
set(handles.axes4,'Color',[0.306 0.396 0.58]) % Change the background color
legend('Current I(A)'); % show legend
xlabel('Time(s)'); % x label
axis auto; % automatic scales of the axis
grid on; % Enable the grid
end