PRACTICAL MATLAB® FOR ENGINEERS PRACTICAL MATLAB

(sharon) #1

Direct Current and Transient Analysis 181


MATLAB Solution
% Script file: RL _ vol _ plots
itR _ 1=dsolve(‘Dy+y=10’,’y(0)=0’,’t’);
itR _ 2=dsolve(‘Dy+2*y=10’,’y(0)=0’,’t’);
itR _ 5=dsolve(‘Dy+5*y=10’,’y(0)=0’,’t’);
disp(‘*********** R E S U L T S **************’)
disp(‘*****************************************’);
disp(‘The voltages across R = 1, 2 and 5 (in Ohms) are:’);
disp(‘***************************’);
disp(‘***************************’);
vr_1=itR_1*1
disp(‘***************************’);
vr _ 2=itR _ 2*2
disp(‘***************************’);
vr_5=itR_5*5
disp(‘***************************’);
figure(1)
ezplot(itR _ 1*1,[0 4]);
hold on
ezplot(itR _ 2*2,[0 4]);
hold on
ezplot(itR _ 5*5,[0 4]);
hold on
grid on;axis([0 3 0 11])
xlabel(‘time t/sec’)
ylabel(‘voltage ‘)
title(‘Voltages across R for, R=1,2 and 5 ‘)
figure(2)
disp(‘***************************’);
disp(‘The voltages across L=1’)
disp(‘ for R=1,2 and 5 (in Ohms) are:’);
disp(‘***************************’);
disp(‘***************************’);
vlr _ 1=10-itR _ 1*1
disp(‘***************************’);
vlr _ 2=10-itR _ 2*2
disp(‘***************************’);
vlr _ 5=10-itR _ 5*5
disp(‘***************************’);
ezplot(10-itR _ 1*1,[0 4]);hold on
ezplot(10-itR _ 2*2,[0 4]);hold on
ezplot(10-itR _ 5*5,[0 4]);
hold on
grid on;axis([0 3 0 11])
xlabel(‘time t/sec’)
ylabel(‘voltage ‘)
title(‘Voltages across L=1, for R=1,2 and 5’)

The script fi le RL_vol_plots is executed, and the results and plots are shown as follows:
>> RL _ vol _ plots
*******************R E S U L T S ********************
******************************************************
The voltages across R = 1, 2 and 5 (in Ohms) are:
******************************************************
Free download pdf