Académique Documents
Professionnel Documents
Culture Documents
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')
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')
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')
% 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')