Understanding of plotting graphs on MATLAB:

Q: If R = 10 Ohms and the current is increased from 0 to 10 A with increments of  2 A,

Write MATLAB programs to plot:

a) I-V

Commands on m-file

R=[10];

% current is increased from 0 to 10A with increments of 2A

I=[0 2 4 6 8 10];

V=I*R

% To plot the graph between current and voltage

plot (I,V)

title(‘graph between current and voltage’)

xlabel(‘current in amperes’)

ylabel(‘voltage in volts’)

grid

 

Graph between I-V

b) I-P

Commands on m-file

R=[10];

% current is increased from 0 to 10A with increments of 2A

I=[0 2 4 6 8 10];

P=I.^2*R

% To plot the graph between current and power

plot (I,P)

title(‘Graph between Current and Power’)

xlabel(‘Current in amperes’)

ylabel(‘Power in watts’)

grid

Graph between I-P

(c) I-V and I-P on same graph

Commands on m-file

R=[10];

% Current increased from 0 to 10A with the increment of 2A

I=[0 2 4 6 8 10];

% to calculate Voltage

V=I*R

% to calculate Power

P=I.^2*R

plot(I,V,’b’,I,P,’r’)

title(‘Graph between I-V and I-P’)

xlabel(‘Current (Amperes)’)

ylabel(‘Voltage (Volts) and Power (Watts)’)

grid

Graph between I-V & I-P

Share this with your friends