Anda di halaman 1dari 25

Revision Sheet For MATLAB

The following sheet contain some problem with a suction


sample please try to do your bets to gain the maximum
benefits. The sheet contain theoretical part, command line part
,m-file and function file part, as well as Simulink part
VIP HINTS
*Please in all of the following parts try to show how to
run each m-file program , function file or command lines
and show the results as possible as you can
* When using plot command please assign the different
labels on the x-y axis and put a suitable title for each
figure
a) During debugging process of MATLAB programs,
there are many types of errors may appear. Explain
them briefly?
*Syntax Errors: the violation of the rule for the specified
language, the program will not be compiled. This usually
caused by missing left or right parentheses, misspelled
commands, or other types. Solution :check the listed line of
code for the syntax error and correct it then test the program
again.
* Logical error-wrong answer: it is the most difficult to
locate, this error is usually caused by a misplaced parentheses
(or lack of parentheses especially in the denominator of a
fraction), reserved or incorrect +/- signs, or the wrong
variables used in an equation. Solution: Break down large
equations into smaller, less complicated steps, and display the
results of the intermediate steps (remove the semi-colons ; ).
Remember the key board interrupt will allow you to pause a
program within a loop and display intermediate values.
* logical error-program terminates early: sometimes it is
called a Run time error since all syntax are good but if you
put a mathematical violation. this error is usually caused by an
index that exceeds matrix dimensions, a variables that doesn't
exist (or has been misspelled), or and indexed variables should
not be indexed (or visa-versa)
Solution: list the size of the variables using the "whos"
MATLAB command .look for the missing variables or incorrect
dimensions (especially for the transposed vectors/matrices). If
the error occurs in a loop, examine the loop index to see what
was the last value of the index.
*GHOST characters: This is a character that is not displayed
on the screen or when printed, but it is recognized when
compiled. If you are sure that a line of code is correct, but the
1

MATLAB won't compile it or run it, it is possible that there is a


"GHOST" character in the line. Since you can't edit this
character, the solution is to delete the entire line of code and
retype the line from the keyboard. While "ghost" characters
should not appear in a file, it has been my experience that
they do show up every once in a while. If you really think that a
line of code is correct, it just might be correct

b) With the aid of block diagram representing the


general form of Simulink model define what is meant by
MATLAB SIMULINK?, and WHAT is simulink good for?
C) State some of the basic features of the MATLAB
software package?
ANS: *MATLAB is a numeric computation software for
engineering and scientific calculations. The name MATLAB
stands for MATRIX LABORATORY.
*MATLAB is primarily a tool for matrix computations.
*MATLAB is a high-level language whose basic data type is a
matrix that does not require dimensioning.
*There is no compilation and linking as is done in high-level
languages, such as C or FORTRAN.
*Computer solutions in MATLAB seem to be much quicker than
those of a high-level language such as C or FORTRAN.
*All computations are performed in complex-valued double
precision arithmetic to guarantee high accuracy. MATLAB has a
rich set of plotting capabilities.
*The graphics are integrated in MATLAB.
*Since MATLAB is also a programming environment, a user can
extend the functional capabilities of MATLAB by writing new
modules.
*MATLAB has a large collection of toolboxes in a variety of
domains. Some examples of MATLAB toolboxes are control
system, signal processing, neural network, image processing,
and system identification. The toolboxes consist of functions
that can be used to perform computations in a specific domain.
*Moreover the MATLAB contain a SIMULINK. It is a software
package for modeling, simulating, and analyzing dynamic
systems. It supports linear and nonlinear systems, modeled in
continuous time, sampled time, or a hybrid of the two. Systems
can also be multirate, i.e., have different parts that are
sampled or updated at different rates
2

PART_I- basic operation using command


i 4
2 e 3
A
7 9

3 8

1.

2
100
7 j

42 B A 2

Represent A, B using Matlab


A = [ j , 4, 2 ; 2, exp (-3), 100 ; 7, 9, 7-j; 3, 8, 42]
B = A . ^ 2 % element by element square as A is not a
square matrix

2- Write MATLAB expression using command lines to achieve


the following:
a) Select just the second row of B
B (2, :)
b) Evaluate the sum of the second row of B
Sum (B (2,:)
c) Multiply the second column of B and first column of A
B (:, 2) *. A (: ,1) (element by element
multiplication)
Or B ( : , 2) * A (:, 1) ' (Vector multiplication so one
of the 2 vectors must be transposed)
d) Evaluate the maximum value in the vector resulting from
element by element multiplication of second column of B
with first column of A
max (B ( : , 2) * A (:, 1) )
e) Evaluate the sum of the first row of A divided element by
element by the first three elements of the three
elements of the third column of B
Sum (A (1, :) . / B (: , [1: 3] ) ' ) % dividing a row
element by element by a column so we must
transpose one of them
f) Convert matrix A into matrix of dimension (6X2).
Reshape ( A , 6, 2)
g) find the transpose of B
3

B'
h) calculate A-1 .B
inv (A) * B
i) multiply first element at the third row of A by the third
element at the first column of B
A (3,1) * B (3, 1) % scalar multiplication, so no
need to put the . operator
2-Using MATLABE function file line to evaluate the complex
number Z in both polar and rectangular form given as
Z=(1-i).e3 sin-1(0.5).(3+4j)-1.e-j30 .5450
Solution:
Z1 = (1 i) * exp (3*pi)
Z2 = asin (0.5) * 1 / (3 + 4* j) % asin is the representation of
sin -1 in Matlab
Z3 = exp ( - j * 30) * 5 exp (j * 45 * pi / 180) % theta rad = theta
degree * pi /180
Z = Z1 * Z2 * Z3
II-Polynomials operations and symbolic

Solution:
Note: Symbolic Math will not come in the exam, so
question 10 is not required

4- [ q, r ] = deconv ( [ 14, -6, 3, 4 ] , [ 5, 7, -4] ) % where


q is the quotient () , r is the remainder (
)
5 y = 0.5 + j * 6 + 3.5 * exp (j * 0.6) + ( (3 + j *6) * exp
( j * 0.3 * pi) )
6 r = roots ( [ 1, 3, 4, 2, 6] )
To plot f (x) there are 2 methods: the first is
repsresnting f (x) as a symbolic function (which will not
come in the exam) and the second is representing f (x)
as a polynomial
Assume x is in the range from -2 <= x <=2 with a step
= 0.5
So the solution as a script file will be:
1- p= [1, 3, 4, 2, 6]
2- x = -2 : 0.5 : 2
3- y = polyval (p, x)
4- plot (x, y)
the required 7, 8 will be solved as no. 4 but with
changing the coefficients
9 result = conv ([ 14, -6, 3, 4 ] , [ 5, 7, -4 ] ) % conv is
the polynomial convolution function which multiplies 2
polynomials together
----------------------------------------------------------------------------------------Part_ 2 application of Function and M. files in MATH.
Pleas in all of the following parts try to show how to run
each m-file program , function file or command lines
and show the results as possible as you can
1-Write a general matlab script m-file to plot the two functions
in the same figure with different line style assign the different
lables on the x-y axis and put a suitable tiltle for each figure
Solution:
1- x1 = 0 : 0.5 : 5
2- x2 = -6: 0.5 : 6
3- f = exp (-1.2 *x ) * sin (10*x + 5)
4- y = abs (x . ^ 3 100)
5

5- plot (x1,f)
6- xlabel ('x1')
7- ylabel ('f (x) ')
8- title (' exponential_sinusoidal function ')
9- legend (' f (x) ')
10hold on
11plot (x2,y)
12xlabel ('x2')
13ylabel ('y ')
14title (' absolute cubic function ')
15legend (' y ')
2- Write a script file to plot the polynomial
Over the range -6 <= x < 6with spacing of 0.01
Solution:
1- x = -6 : 0.01: 6
2- p = [2 , 2, -100, -2, -7, 90 ] % polynomial of degree
5 has 6 coefficients
3- y = polyval (p , x)
4- plot (x, y)
3-Write a functional file to evaluate n factorial (i.e. n!) where
n ! = n (n-1) (n-2)
(n-3).(2 )(1)
Solution:
function fact = factorial (n)
n = input (' enter a number ')
fact = 1
for i = 1 : n
fact = fact * i
end % end of the for loop
fact % the function returns the value of fact
end % end of the function file
4- Write a MATLAB function to add all the odds numbers from 0
to n (at each run n
is changed) Add all the terms in the series

Print out the sum of 10 terms


6

Solution:
12345-

function [ sum ] = series (n)


n = input ('Enter the number of terms of the series')
sum = 0
for i = 1 : n
sum = sum + 1 / ( (2 * i ) + 1 ) % the general term = 1 /
(2i + 1)
6- end % end of the for loop
7- sum % return the value of sum
8- end % end of the function file
To run this general function File press f5 (or from the Debug
Menu select Run)
When the Command Windows appears, this message will
be displayed
>> Enter the number of terms of the series
>> n = 10
The output will be: 1 + 1/3 + 1/5 + 1/7 + 1/9 + 1/11 +
1/13 + 1/15 + 1/17 + 1/19 = 0.05595 ( not required)
5-Given a set of integers ranged from 0 to N, Write a MATLAB
function to assign the even and odd numbers in each case
find the sum of each part
6- Write a MATLAB function to add all the numbers according
to the following series
1+2+4+6+8+.
Solution:
12345678-

function [ sum ] = series (n)


n = input ('Enter the number of terms of the series')
sum = 1
for i = 2 : n
sum = sum + ( i - 1 ) * 2
end % end of the for loop
sum % return the value of sum
end % end of the function file

7- Write a MATLAB function to add all the numbers according


to the following series

x2
Z
x=0

Solution:
12345678-

function [ sum ] = series (n)


n = input ('Enter the number of terms of the series')
sum = 0
for i = 0 : n
sum = sum + ( i ) ^ 2
end % end of the for loop
sum % return the value of sum
end % end of the function file

8- Determine the number of consecutive integer numbers


which when added together will give a value "max_value".
Run such program for max_value= 210.
Example 3.3, page 34 (Lecture Book) (using while loop
and if statement)
9- Write MATLAB script file to show and generate the following
series ( numbers from 0 to n )
1 ,2 , 4 , 9, 16 ,25 ,36,
Solution:
1- n = input ('Enter the number of terms of the series')
2- A (1) = 1
3- A (2) = 2
4- for i = 3: n
5- A (i) = ( i 1) ^ 2
6- end % end of the for loop
7- disp (A) % display the vector A
10- Write a MATLAB script file to show and generate the
following series
(numbers from 0 to n). The recursion
relation is assumed according to the following
Ai = Ai-1 + Ai-2
i.e the new term starting from the third term is sum of the two
previous terms as follows
1 ,1 ,2 ,3 ,5 ,8,13,21,34
8

Solution:
1- n = input ('Enter the number of terms of the Fibonacci
series')
2- A (1) = 1
3- A (2) = 1
4- for i = 3: n
5- A (i) = A (i-1) + A (i-2)
6- end % end of the for loop
7- disp (A) % display the vector A
Part_ 3 application of Function and M. files in
electronics.

11- For in the op. Amp shown, in figure (a ) Derive the


expression for the transfer function. Then write general matlab
script file to find the frequency response for such amplifier ,
Explain how to run such file assuming the following values
(b) If C = 1 nF and R1 = 2K, plot the magnitude response for
the different values of R2 as follows equal to
(i) 100 K, (ii) 300K, and (iii) 500K.

Sample of MATLAB Script r try to play it as general file


% Frequency response of lowpass circuit
C=input(plz enter the value of
c = 1e-9; r1 = 2e3;
r2 = [100e3, 300e3, 500e3];
n1 = -1/(c*r1); d1 = 1/(c*r2(1));
num1 = [n1]; den1 = [1 d1];
w = logspace (-2,6);
h1 = freqs (num1,den1,w);
f = w / (2*pi);
12- For the non-inverting type O.A shown in Figure below (a)
Derive the transfer function. (b) Use MATLAB general m-file to
find the poles and zeros and Plot the magnitude and phase
response,. Explain how to run such file assuming the following
values: C1 = 0.1uF, C2 = 1000 0.1uF, R1 = 10K, and R2 =
10 .

10

11

13- In the above Figure 11.15, of finite gain O.A write a


matlab script m-file to drive the above expression then assume
R1 = 500 , and R2 = 50 K Plot the closed-loop gain as
the open-loop gain increases from 102 to 108 .

14- The following example illustrates the effect of a finite


CMRR on the closedloop gain of a non-inverting For the
amplifier shown in Figure 11.22, if R2 = 50Kand R1 = 1K,
plot
12

the closed-loop gain versus CMRR for the following values of


the latter:
104 , 105 , 106 , 107 , 108 and 109 .amplifier.
% Non-inverting amplifier with finite CMRR
r2 = 50e3; r1 = 1.0e3; rr = r2/r1;
cmrr = logspace(4,9,6); gain = (1+rr)*(1+1./cmrr);
semilogx(cmrr,gain,'wo')
xlabel('Common-mode Rejection Ratio')
ylabel('Closed Loop Gain')
title('Gain versus CMRR')
axis([1.0e3,1.0e10,50.998, 51.008])
15-For the genral RC circuit Figure 5.2, write MATLAB function
file to study the case of charging and discharging the capacitor
if the input voltage is a rectangular pulse with an amplitude of
5V and a width of 0.5s. If C = 10 uF, plot the output voltage,
vo( t), for resistance R equal to (a) 1 Kohm and (b) 10 K. The
plots should start from zero seconds and end at 1.5 seconds.

For the series RLC circuit the transfer function (T.F) is given as:

13

Write a general MATLAB program to obtain the magnitude and


phase response, as well as calculate the poles,zeros, and gain
of this T.F. Run such program for the given values:
If L = 5 H, C = 1.12 uF, and R = 10000 ohm, plot the
frequency response.
16) After performing the DC_ analysis of a certain electrical
circuit using NODAL VOLTAGE technique, the following
equations are concluded:
5 V1 -3 V2 -8 V3 =10
0.4 V1 -0.7 V2 -1.5 V3 =0
15 V1 -25 V2 -14 V3 =2
Where all the above coefficients are representing [Y] matrix.
Write a MATLAB script file to solve such problem guided with
the equation in matrix form: [V] =[Y] -1 [I]
17) Write a MATLAB function file to calculate equivalent
resistance for group of series and parallel connected
resistance. Display suitable messages in each case. Then show
different steps to run this function for the values R=10,20 and
30 .
function [ rs rp ] = rsp( r )
%UNTITLED2 Summary of this function goes here
% Detailed explanation goes here
rs=sum(r); % statement for the equivalent series resistance
g=1./r;% statement for the conductance
gs=sum(g);% statement for the equivalent series conductance
rp=1/gs;% statement for the equivalent parallel resistance
end
Another Solution (using for loop)
function [ rs, rp ] = rsp ( r )
r=input('Enter n resistances')
rs = 0;
rp = 0;
for i = 1 to length (r)
rs = rs + r(i);
rp = rp + 1 / r(i);
end % end of the for loop
rs
1/rp
14

end % end of the function file


to run such function usingcommand windows as follows

a) The voltage V, across a resistance is given as (Ohms law)


V=RI, where R is the resistance, and I is the current. The power
dissipated in resistor R is given by the expression P=RI 2 . Write
a general MATLAB script file to calculate the voltage and
power across resistance R. Then show how to run the program
to test the result if R=10 and the current I is ranged from 0
to 10 A with increments of 2A.
% general program for power calculation diary ex1_1.dat
clear all close all
seta=input('enter the phase shift between current and voltage
seta=')
setar=seta*pi/180;
%pf=cos(setar);% power factor
y=input('index y=1 given I,V- y=2 given R,V y=3 given R,I
y=')
pf=cos(setar);% power factor
if y==1
I=input(' enter the value of current I=') ;
V=input(' enter the value of current V=') ;
P=I.*V.*pf % general form of power
elseif y==2
R=input(' enter the value of resistance R=') ;
V=input(' enter the value of voltage V=') ;
P=V.^2./R.*pf % general form of power
else
R=input(' enter the value of resistance R=') ;
I=input(' enter the value of current I=') ;
P=I.^2.*R.*pf % general form of power
end
15

HINT for SIMULINK:


GENERALLY: Open the MATLAB
SIMULINK tool box using the start menu of the MATLAB or using
the command window >> Simulink. Or using the toolbox icon
.
then from the Simulink toolbox apply the following
sequence to create a new model file
File-Newmodelcreate new model
Apply the rule of drag and drop from the different library to get
the different SOURCE- library" and different "SINK- library" to
create the model for the different problem. By double click for
the different box we can establish the different parameters.
And then click on the play toolbox to run the model we
designed
From source library drag and drop the "ramp" function box
From the sink library drag and drop the "scope" function box
From the continuous library drag and drop "transfer fcn" box
And so on foe all the other library according to the given
problem (hint try to use the search command box to search

16

about the unknown boxes) and FINALLY DRAW THE MODEL


ACCORDING TO THE GIVEN PROBLEM
a) Construct simulation diagram satisfying the equation
x(t)= 10sin(100t+20cos(100t)+30t
b) Explain how to use SIMULINK tool box to model the equation
that convert Celsius temperature to Fahrenheit as: Tf= 9/5
Tc+32 Obtain a display of Fahrenheit-Celsius temperature
graph over range of 0 to 1000C

Solution:
General Simulink Model:
Source
(input
waveforms or
imported
from an
external file )

System
(interconnected
links between
different blocks
like integrator,
derivative,
Multiplexer,

Sink
(output either on
scope or exported
to an external file)

Applying this model on the given problem:


1- Open the Simulink from Matlab Command Window
>> simulink
2- Once the Simulink is opened, the Simulink Library Browser
(the place of the system components and blocks) appears
3- From the Simulink Library Browser menu open the file menu
then new then model
4- In the model window design the model of the given problem
using the drag and drop concept (drag the blocks from the
Simulink library browser and then drop them with the suitable
connections in the model)
To model the equation that converts Celsius temperature to Fahrenheit
TF = 9/5(TC) + 32
First, consider the blocks needed to build the model:

A Ramp block to input the temperature signal, from the Sources library

A Constant block to define a constant of 32, also from the Sources library
17

A Gain block to multiply the input signal by 9/5, from the Math Operations
library

A Sum block to add the two quantities, also from the Math Operations library

A Scope block to display the output, from the Sinks library


Next, gather the blocks into your model window.

Assign parameter values to the Gain and Constant blocks by opening (doubleclicking) each block and entering the appropriate value. Then, click the OK button to
apply the value and close the dialog box.
Now, connect the blocks.

The Ramp block inputs Celsius temperature. Open that block and change the Initial
output parameter to 0. The Gain block multiplies that temperature by the constant
9/5. The Sum block adds the value 32 to the result and outputs the Fahrenheit
temperature.
Open the Scope block to view the output. Now, choose Run from
the Simulation menu to run the simulation. The simulation runs for 10 seconds.

18

Part one Mathematical Manipulation


3i

2
A
7

4 2

4 100
9 7

8 42 B A 2

1-Write MATLAB expression to do the following


a) Select just the second row of B
b) Evaluate the sum of the second row of B
c) Multiply the second column of B and first column of A
d) Evaluate the maximum value in the vector resulting from
element by element multiplication of second column of B
with first column of A
e) Evaluate the sum of the first row of A divided element by
element by the three elements of the three elements of
the third column of B
f) Convert matrix A into matrix of dimension (6X2).
19

2-Using MATLABE to evaluate the complex number


z

(3 j 4)( 6 j 6)
7 j10
(2 j1) j 2

11 4
12 2

17

30
10

42 B e A

3Show how to represent A, B in Matlab


A = [11 , 4, 30; 12, 2*pi, 10; 17, 9, 5*pi; 3, pi, 42]
B= exp (A)
Write MATLAB expression to do the following
a) Select just the third row of B
B (3, :)
b) Evaluate the sum of the first row of B
sum (B (1, :) )
c) Multiply the second column of A and first column of B
A (: , 2) . * B (:, 1) (element by element multiplication
so we need to use .*)
Or: A (: , 2) * B (: , 1) ' (normal matrix multiplication so we
need to transpose one of the 2 matrices)
d) Evaluate the maximum value in the vector resulting from
element by element multiplication of second column of B
with first column of A
max ( (B (: , 2) . * A (: , 1) )
e) Evaluate the sum of the first row of A Multiplied element
by element by the three elements of the three elements
of the third column of B
sum ( A (1, :) . * B (: , [1:3] ) ' ) ( element by element
multiplication of rows and columns so we need to
transpose one of them )
Polynomials
4 -Using MATLAB to find the quotient and reminder of
14 x 3 6 x 2 3x 4
5x 2 7 x 4

P = [14, -6, 3, 4] (polynomial of degree 3 having 4 coefficients)


Q = [5, 7, -4] (polynomial of degree 2 having 3 coefficients)
20

[a, b] = deconv (P, Q) (where a will be the quotient


(coefficients ) while b will be the remainder
(coefficients )
5- Using MATLABE to simplify the expression
y 0.5 j 6 3.5e j 0.6 (3 j 6)e j 0.3

6-Using MATLABE to find the roots of


f ( x) x 4 3x 3 4 x 2 2 x 6

f (x)

using two methods plot


7-Using MATLAB to find the quotient and reminder of
10 x 3 9 x 2 6 x 12
5 x 3 4 x 2 12 x 8

8- Using MATLAB to find the quotient and reminder of


8x3 9x 2 7
10 x 3 5 x 2 3 x 7

9- Using MATLAB to find the multiplication of the following


functions
f 1( x) 14 x 3 6 x 2 3x 4, f 2 ( x) 5 x 2 7 x 4

f1 = [14, -6, 3, 4]
f2 = [5, 7, -4]
F = conv (f1, f2)

Part 2 Function and M. files


1-Write a script file to plot the two functions in the same figure
with different line style
y x 3 100

f ( x) e 1.2 x sin(10 x 5) for 0 x 5

6 x 6

and function
for
2-Write a functional file to evaluate n factorial (i.e. n!) where
n ! = n (n-1) (n-2)
(n-3).(2 )(1)
x

7!
3! 4!

Using the function to compute


3- Write a MATLAB function to add all the odds numbers from 0
to n (at each run n is changed)
Add all the terms in the series
1

1 1 1
1
..........
where n 0,1,2.....
3 5 7
2n 1

Print out the sum of 10 terms


21

4- Write a for loop that is equivalent to the command sum(A)


1

24 5
20 13
9 11

24

3
2

24 5
20 13
9 11

24

3
2

24 5
20 13
9 11

24

3
2

12

where
5- Write a for loop that is equivalent to the command max(A)
A

12

where
6- Write a for loop that is equivalent to the command min(A)
A

where

12

v(t ) 10 (1 e 0.2t )

7- The voltage across discharging capacitors is


generate a table of voltage v(t), versus time t, for t=0 to 50
seconds with increment of 5 second find the number of points
of vector t
8- Write a MATLAB function to add all the evens numbers from
0 to n (at each run n is changed)
9- Write a script file to plot the polynomial
2 x 5 2 x 4 100 x 3 2 x 2 7 x 90

Over the range

6 x 6

with spacing of 0.01

Final Exam Notes:


- Most of the questions come in the form of "write a
general M File (without values) then show how to run
this file for the give values "
- Symbolic Math will not come in the exam ()
- Simulink will come as the problem we have solved in the
last section (similar to the last question in the last year
final exam that I have given to you and uploaded on the
group)
22

- Any programming problem taken in C++ can come in the


Matlab exam (like factorial, power, maximum element of
the array using for loop without using the max built-in
function etc)
- According to Doctor Fouda, the supplementary
problems in this sheet are only for understanding buit will
not come in the exam (so, I removed them from the sheet
)
- All the examples in the Lecture Book that Doctor Fouda
has explained are important, and the Doctor takes these
examples into consideration in the final exam. In the next
update of these notes INSHALLAH, I will try to inform
you of the most important problems
- Your Mid - Term Exam of 2015 is very important. I gave
you the model answer of Dr. Fouda which is also
uploaded on the group.

Important Problems and Notes in Lecture Book:


Chapter "1": Matlab Basics and Foundations:
Page "1": 1- Introduction: Definition and Applications of Matlab
Pages "11", "12" : Examples 1.1, 1.2
Pages "15", 16: Ex 1.1, 1.4 (very important), 1.7 (very important)
Chapter "2": Plotting Commands:

23

Page "22", Ex. 2.1


Page "25", Ex. 2.3 (polar plot, very important)
Page "27", Examples 2.3, 2.4, 2.7, 2.8
Chapter "3": Control Statements (Programming using
Matlab:
Page "28": ex. P2.m, page "29": ex. P3.m (Mid Term)
Page "33": ex. 3.2 (A/D Converter, very important)
Page "34", ex. 3.3
Page "39", ex. 3
Page "40", ex. 1.4 (Quadratic Equation)
Chapter "4": DC Analsyis
Chapter "5": AC Analysis, Frequency Response ,
Semiconductors and Op Amps
Notes:
1- In this chapter we need the function "logspace" which takes the
following form:
logspace (power of start frequency, power of end frequency,
number of frequencies)
Example: if doping concentration is from 10

14

to 10

19

cm

-3

Then N d (doping concentration) = logspace (14, 19) (if the number


of frequencies was not given, the logspace takes 2 parameters only)
2- Also we need the freqs function which calculates and represents
the transfer function H (s) in the form of:
H = freqs (num, den, w)

Where num is the numerator of the polynomial H (s)


, den is the denominator of the polynomial H (s)
, w is the omega (w = 2 * pi * f, so f = w / (2 * pi)

24

- So firstly we must represent h (s) as 2 polynomials one for the


numerator ( ), and the other for the denominator (),
each polynomial is in the form of (n+1) coefficients
- Then represent w (omega) in the form of logspace function
(as explained previously)
- Finally calculate h (s) using the freqs function
Important Examples in Chapter "5":
AC analysis : Example "5.1": page 70, Ex. 5.2: pages 71, 72
(Very important)
Frequency Response: Example 6.7: pages "74", "75" (Very
Important)

Chapter "6": Introduction to Simulink:

25

Anda mungkin juga menyukai