Monday, 28 October 2013

Matlab program to find prime numbers: first hundered if n = 100


n = 103; numbers = 2: n; primes = []; for i = 1: length(numbers) if ~ numbers(i) == 0 for j = i+1: length(numbers) if rem(numbers(j), numbers(i)) == 0 numbers(j) = 0 end end end if ~ numbers(i) == 0 primes(length(primes) + 1) = numbers(i) end end primes

Thursday, 24 October 2013

Plotting complex polar graph in MATLAB


Numerical#2 A complex number z can be represented as z = rejθ. The nth power of the complex number is given as Zn = rn ejnθ. If r = 1.2 and θ = 10˚, use polar plot to plot |zn| versus nθ for n = 1 to 36. Solution: % polar plot of z r = 1.2; theta = 10*pi/180; angle = 0:theta:36*theta; mag = r.^(angle/theta); polar(angle,mag, 'g*-') grid title('Polar Plot') The output of the program is shown below in figure:

To plot V(t) and I(t) for an electrical RL circuit: Matlab Program


Numerical # 1 For an R-L circuit, the voltage v(t ) and current i(t ) are given as V(t) = 10cos(377t); i(t) = 5 cos(377t+60˚) Sketch v(t ) and i(t ) for t = 0 to 20 milliseconds. Solution MATLAB Script % RL circuit % current i(t) and voltage v(t) are generated; t is time t = 0:1e-3:20e-3; v = 10*cos(377*t); a_rad = (60*pi/180); % angle in radians i = 5*cos(377*t + a_rad); plot(t,v,'r*',t,i,'go') title('Voltage and Current of an RL circuit') xlabel('Sec') ylabel('Voltage(V) and Current(mA)') text(0.003, 1.5, 'v(t)'); text(0.009,2, 'i(t)') The output of program can be seen in figure below

Wednesday, 23 October 2013

MATLAB program to compute the back EMF and armature current of a DC Motor


clc; clear all; P = input('Number of poles are: '); Phi = input('Flux per pole in Wb is: '); Z = input('Total number of armature conductors are: '); N = input('Armature speed in rpm is: '); V = input('Supply voltage in volts is: '); Ra = input('Armature resistance in Ohms is: '); W = input('1 for lap wining and 2 for wave winding: '); if W == 1 Eb = (Phi * N * Z) / 60; end if W == 2 Eb = (P * Phi * N * Z)/120; end Ia = (V - Eb)/ Ra; disp('Back EMF developed in the motor in volts is:'), Eb disp('Armature current in A is: '); Ia

Sunday, 20 October 2013

Response of RL and RC circuits plot


% To plot response of RL and RC circuits % R = 10, L = 20e-3 H for RL circuit V = 100; % Volts R = 10; % Ohms L = 20e-3; % Henry Im = V/R; to = L/R; t = 0:10e-6:0.02; i = Im*(1-exp(-t/to)); figure(1) plot(t,i) title('Response of R-L circuit') xlabel('T (sec)'), ylabel('i(t)') % R = 100, C = 20e-6 F for RC circuit R = 100; C = 200e-4; Vm = V; to = 1/(R*C) t = 0:10e-6:6; v = Vm*(1-exp(-t/to)); figure(2) plot(t,v) title('Response of R-C circuit') xlabel('T (sec)'), ylabel('v(t)')

Series and parallel resonance response


% This program plot a graph of frequency vs impedance in case of series % resonance clc; clear all; f = 100:1:400; L = 6.34e-3; C = 100e-6; R = 100; XL = 2*pi*f*L; XC = 1./(2*pi*f*C); Z = (R^2 + (XL - XC).^2).^0.5; figure(1) plot(f,Z) title('\bf Impedance vs frequency plot for series resonance'); xlabel('\bf Supply frequency in Hz'); ylabel('\bf Impedance in Ohms'); Z = 1./(1./XL+1./XC); figure(2) plot(f,Z) title('\bf Impedance vs frequency plot for parallel resonance'); xlabel('\bf Supply frequency in Hz'); ylabel('\bf Impedance in Ohms');

Wednesday, 2 October 2013

Design of Seven step multi level inverter


The concept of utilizing multiple small voltage levels to perform power conversion was patented by an MIT researcher over twenty years ago. Advantages of this multilevel approach include good power quality, good electromagnetic compatibility (EMC), low switching losses, and high voltage capability. The main disadvantages of this technique are that a larger number of switching semiconductors are required for lower-voltage systems and the small voltage steps must be supplied on the dc side either by a capacitor bank or isolated voltage sources. The first topology introduced was the series H-bridge design. This was followed by the diode clamped converter which utilized a bank of series capacitors. A later invention detailed the flying capacitor design in which the capacitors were floating rather than series-connected. Another multilevel design involves parallel connection of inverter phases through inter-phase reactors
. In this design, the semiconductors block the entire dc voltage, but share the load current. Several combinational designs have also emergedsome involving cascading the fundamental topologies. These designs can create higher power quality for a given number of semiconductor devices than the fundamental topologies alone due to a multiplying effect of the number of levels.