0% found this document useful (0 votes)
57 views3 pages

MATLAB Program for Resistor Analysis

The document contains Matlab code for several tasks: 1) A program to calculate voltages across resistors in a series circuit and the power dissipated in each resistor. 2) Code to generate simple 2D plots like stem, stairs, pie, and bar plots. 3) Programs to calculate resistance from voltage and current, EMF of a DC generator, and EMF of a transformer. 4) Code for an Ohm's Law I-V plot.

Uploaded by

Harish Gouda
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views3 pages

MATLAB Program for Resistor Analysis

The document contains Matlab code for several tasks: 1) A program to calculate voltages across resistors in a series circuit and the power dissipated in each resistor. 2) Code to generate simple 2D plots like stem, stairs, pie, and bar plots. 3) Programs to calculate resistance from voltage and current, EMF of a DC generator, and EMF of a transformer. 4) Code for an Ohm's Law I-V plot.

Uploaded by

Harish Gouda
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Q: ) Write a matlab program that calculate voltages across each resistor connected in series and power dissipated in each

resistor.

% THIS PROGRAM CALCULATES THE VOLTAGE ACROSS EACH RESISTOR % IN A CIRCUIT THAT HAS RESISTORS CONNECTED IN SERIES vs=input('Enter the source voltage'); rn=input('Enter values of resistors as elements in a row vector\n'); req=sum(rn); % CALCULATING EQUIVALENT RESISTANCE vn=rn*vs/req; % APPLY VOLTAGE DIVIDE RULE pn=rn*vs^2/req/2; % CALCULATING POWER IN EACH CIRCUIT i=vs/req; % CALCULATE CURRENT IN THE CIRCUIT ptotal=vs*i; % CALCULATE POWER IN THE CIRCUIT table=[rn,vn,pn];% CREATE TABLE disp('Resistance Voltage Power') %DISPLAY HEADINGS FOR COLUMNS disp('(ohms) (volts) (watts)') disp(table) % DISPLAY THE VARIABLE TABLE fprintf ('The curent in the circuit is %f amp,i') fprintf('\nThe total power dissipated in the circuit is %f watts\n,ptotal')

simple 2d stem plot


x = 0:0.1:4; y = sin(x.^2).*exp(-x); stem(x,y); grid

simple 2d stairs plot


x=0:0.05:8; stairs(x,sin(x.^2).*exp(-x)); grid

Sample 2D Plot (pie plot) In this example we demonstrate the use of the gtext function to write a string at the location of the mouse acft = char('A310','A330','MD11','DC-10', 'L1011',... 'B747','B767','B777'); numbers=[12 15 24 35 16 120 456 156]; pie(numbers) for i=1:8 % array of strings gtext(acft(i,:)); % get text from char variable end title('Aircraft Performing N. Atlantic Crossings')

simple 2d bar plots

x = -2.9:0.2:2.9; bar(x,exp(-x.*x)); grid

write a matlab program to find the resistance for the given voltage and current

v=input('enter the value of voltage'); i=input('enter the value of current'); r=v/i disp('ohm')

write a matlab program to find the emf generated in a dc generator E=phi*z*n*p/60*a.

% calculating emf equation of a dc generator phi=input('enter the value of flux/pole in webers'); z=input('enter the value of number of conductors'); p=input('enter the value of number of poles') a=input('enter the value of number of paralel paths'); n=input('enter the value of speed in rpm'); E=phi*z*p*n/60*a disp('volts')

write a matlab program to find the emf equation of a transformer E=4.44*phi*f*n1. % calculating emf equation of a transformer phi=input('enter the value of flux/pole in webers'); f=input('enter the value of flux in hertz'); n1=input('enter the value of number of turns in rpm'); E=4.44*phi*f*n1 disp('volts')

OHMS PLOT r=5; e=0:5:30; i=e/r plot(e,i),grid on xlabel('e(volts)'),ylabel('i(ampers)')

You might also like