Beruflich Dokumente
Kultur Dokumente
Electrical Machines
Dated:
Semester:
Spring, 2016
Session:
BS-EE-13
Name
Reg. No.
Report
Marks / 10
Viva
Marks / 5
Total / 15
5|Page
1.1.2 Step 2
Click Desktop >> Desktop Layout >> Default
1.
2.
3.
4.
5.
Current folder
Command window
Workspace
Current folder
Start Button
6|Page
7|Page
i.
ii.
1. Using MATLAB, Claculate sum and product for above matrix X and A?
_______________________________________________________________________
2. X * A = A* X__________________________________________________(True/False)
>> size(x)
>> x
8|Page
3.
4.
5.
6.
7.
8.
Matrix Indexing:
Colon Operator:
To pic certain portion of matrix
To pic jth column of x
To pic ith row of x
Linear Spacing (row vector)
>>
>>
>>
>>
>>
x(i,j)
% i is row number and j is colom number
x = 0:1:10;
x(m:n,k:l )% specifies rows m to n and column k to l.
x(:,j)
x(i,:)
9|Page
4. To extract
1. Finding roots
Roots_p1 = Root (p1)
2. Finding polynomial from roots
Poly (roots_p1)
3. Finding value of polynomial at any value
Polyval (p1, x)
4. Multiplication of two polynomial
Conv (a, b)
5. Division of two polynomials
>> diff(E,v)
>> diff(E,n)
>> diff(S,v,n)
1.5.1.1 Example:
>> syms p q
>> diff(y,p)
>> diff(y,q,2)
1.5.2 Integration
Indefinite integral of symbolic expression E with respect to its sym-bolic variable as defined by
find sym.
10 | P a g e
1.5.2.1 Example
>> int(y)
>> int(y,p,a,b)
We can solve system of linear equation (value of x, y and z) by using following commands
>> A = [1 2 3; 4 5 6; 7 8 0];
>> B = [1; 1; 1]
>> X = inv(A)*b
Or
X = A\B
11 | P a g e
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
1.7.1.2 Method 2:
>>
>>
>>
>>
x=linspace(0,2*pi,60);
y=sin(x);
plot(x,y)
grid on
1.7.1.3 Method 3:
>> x=linspace(0,2*pi,60);
>> plot(x,sin(x))
Plot (x, y, x, u, x, v)
Plot (x, y,cms) % c is color code, m is marker type (*), s is line style (-)
x=linspace (0,2*pi,60);
plot(x,sin(x),'r',x,cos(x),'b',x,cos(x+20),'g')
grid on
12 | P a g e
=
Domain should be (-
) and
( )
14 | P a g e
function f = factorial(n)
(1)
% FACTORIAL(N) returns the factorial of N.
(2)
% Compute a factorial value.
(3)
f = prod (1: n);
(4)
The first line of a function M-file starts with the keyword function. It gives the function name and order
of arguments. In the case of function factorial, there are up to one output argument and one input
argument.
In addition, it is important to note that function name must begin with a letter, and must be no longer
than the maximum of 63 characters to plot a saved function specify name and limits of x [min max]
15 | P a g e
for I = 0: 2: 10
fprintf(yasir)
end
16 | P a g e
1.8.9.1.2 Step 2
You will have an empty editor to enter list of commands
1.8.9.1.3 Step 3
Now, press the green button to execute the program.
18 | P a g e
When you enter temperature in centigrade and press enter; Command window will show you value in
kelvin.
You can use the function in any script file in same way.
20 | P a g e