Vous êtes sur la page 1sur 3

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)')

Vous aimerez peut-être aussi