A blog to help electrical engineers and students to learn electrical engineering topics. Basic Electrical Engineering, Power Systems, Electrical Machines, tec.. Now special course on MATLAB for Beginners.



Wednesday, September 21, 2016

MATLAB Scripts - Examples with Electrical Engineering Applications

This lecture we will practice some Basic MATLAB Scripts.
›We will start with simple scripts and will discuss some electrical engineering applications.

Program to calculate Electricity bill.

w = input('Enter power of your device (in watts): ');
h = input('Enter time (in hours): ');
r = input('Enter electricity rate (in dollars per KWH): ');
ec = w * h/1000 * r;
disp(’Your Electricity bill is’)

Power transfer vs Load resistance curve

RL = 1:0.01:10;
Vs = 12;
Rs = 2.5;
P = (Vs^2*RL)./(RL+Rs).^2;
xlabel('Load resistance')
ylabel('Power dissipated')

Torque-Speed Curve for a squirrel cage Induction Motor 

›Ns=1500; % Synchronous speed;
›R1=15.6 ;R2=14;X1=18; X2=23;Xm=260;Vt=400/sqrt(3);
›s = 0.002:0.002:1; % vector of slip
›N = Ns.*(1-s); % Speed, in RPM
›Ws = 2*pi*Ns/60; % Synchronous speed in rad/sec
›Rr = R2./ s; % Rotor resistance
›Zr = j*X2 + Rr; % Total rotor impedance
›Za = j*Xm*Zr./(j*Xm+Zr); % Air-gap impedance
›Zt = R1 + j*X1 +Za; % Terminal impedance
›Ia = Vt ./ Zt; % Terminal Current
›I2 = j*Xm*Ia./(j*Xm+Zr); % Rotor Current
›Pag = 3* (abs(I2)).^2.*Rr; % Air-Gap Power
›Pm = Pag.* (1-s); % Converted Power
›Trq = Pag/ Ws; % Developed Torque
›plot(N, Trq)
›xlabel('Speed in RPM')
›ylabel('Torque (Nm)')
›plot(Ia, Trq)
›xlabel('Load Current')
›ylabel('Torque (Nm)')

Saturday, September 10, 2016

Introduction to MATLAB Scripts

MATLAB Script or programs are sequences of MATLAB commands saved in plain text files. When you type the name of the script file at the MATLAB prompt the commands in the script file are executed as if you had typed them in command window. Code for a script is done in an Editor window and saved as m-file. 

In case your code has errors, MATLAB will show an error message in the command window, when you try to run the program . Error message will be hyperlinked to the line in the file that caused the error.

Script variables are added to the workspace. —If you use the same variables in another script, they will be modified by that script. —This may result in a confusing mix of variables in the MATLAB workspace. —Some times it may lead to a syntax error or may lead to subtle errors in the result.

Sunday, September 4, 2016

MATLAB Programming Tips 2 - Input and Output Commands

In this lecture we will review some common input and output commands in MATLAB. These commands are discussed in detail in previous lectures.
For detailed Lectures on Input and Output commands follow the links below.