Sunteți pe pagina 1din 20

LAB TASK NO #1

INTRODUCTION TO MATLAB
What is MATLAB?
MATLAB, short for MATRIX LABORTORY is a programming package specifically
designed for quick and easy scientific calculations and I/O. It has literally hundreds
of built-in functions for a wide variety of computations and many toolboxes
designed for specific research disciplines, including statistics, optimization,
solution of partial differential equations, data analysis
MATLAB helps you take your ideas beyond the desktop. You can run your
analyses on larger data sets, and scale up to clusters and clouds. MATLAB code
can be integrated with other languages, enabling you to deploy algorithms and
applications within web, enterprise, and production systems.

Starting MATLAB:
The major tools within or accessible from the desktop are:

• The Command Window


• The Command History
• The Workspace
• The Current Directory
• The Help Browser
• The Start button

The graphical interface to the MATLAB workspace:


Figure 1.1
When MATLAB is started for the first time, the screen looks like the one that
shown in the Figure 1.1.

Prompt:
You are now faced with the MATLAB desktop on your computer, which contains
the prompt (>>) in the Command Window. Usually, there are 2 types of prompt.

Types of prompt:
 >> for full version
 EDU> for educational version
Note: To simplify the notation, we will use this prompt, >>, as a standard prompt
sign, though our MATLAB version is for educational purpose.

Using MATLAB as a calculator:


Simple interactive calculation, just type the expression you want to evaluate. Let’s
start at the very beginning. For example, let’s suppose you want to calculate the
expression, 1 + 2 × 3. You type it at the prompt command (>>) as follows.

Example:
>> 1+2*3
ans = 7
Quitting MATLAB:
To end your MATLAB session, type quit in the Command Window, or select File
−→ Exit MATLAB in the desktop main menu.

Creating simple plots:


The MATLAB command to plot a graph is plot(x,y). The vectors x = (1, 2, 3, 4, 5, 6)
and y = (3, −1, 2, 4, 5, 1) produce the picture shown in Figure 2.1.

Example :
>> x = [1 2 3 4 5 6];
>> y = [3 -1 2 4 5 1];
>> plot (x,y)

Figure2.1:
Matrix generation:
Matrices are fundamental to MATLAB. Therefore, we need to become familiar
with matrix generation and manipulation. Matrices can be generated in several
ways.

Entering a vector:
A vector is a special case of a matrix. The purpose of this section is to show how
to create vectors and matrices in MATLAB. As discussed earlier, an array of
dimension 1 ×n is called a row vector, whereas an array of dimension m × 1 is
called a column vector. The elements of vectors in MATLAB are enclosed by
square brackets and are separated by spaces or by commas.

For example:
To enter a row vector, v, type

>> v = [1 4 7 10 13]
v =
1 4 7 10 13
Column vectors are created in a similar way, however, semicolon (;) must
separate the components of a column vector,
Example:
>> w = [1;4;7;10;13]
w=
1
4
7
10
13
Array operations:
MATLAB has two different types of arithmetic operations: matrix arithmetic
operations and array arithmetic operations. We have seen matrix arithmetic
operations in the previous lab. Now, we are interested in array operations.

Array arithmetic operations:


On the other hand, array arithmetic operations or array operations for short, are
done element-by-element.

Example:
>> C = A.*B

produces another matrix C of the same size with elements cij = aij bij . For example, using the same 3 × 3
matrices,

A= [1 2 3 B= [10 20 30

456 40 50 60

789] 70 80 90 ]

Answer:
>> C = A.*B
C=
10 40 90
160 250 360
490 640 810

Output commands:
MATLAB automatically generates a display when commands are executed. In
addition to this automatic display, MATLAB has several commands that can be
used to generate displays or outputs.
Two commands:
that are frequently used to generate output are: disp and fprintf.
LAB TASK NO#2
LAB TASK NO#3
To solve transfer functions of different electrical
networks in MATLAB(Simulink)
OBJECTIVE:
To model and analyze any system like electrical, mechanical, hydraulic and
pneumatic etc.
To solve transfer function for electrical networks including passive elements.
Simulink:
Simulink, developed by MathWorks, is a graphical programming environment for
modeling, simulating and analyzing multidomain dynamical systems.

How to open Simulink in MATLAB?


To open Simulink open the MATLAB command window first. Click on the icon
which is present in the toolbar in the command window of MATLAB.
How we use Simulink?
 First open the matlab software
 Select the Simulink option present top of matlab.
 Again one more window open after open the Simulink
and many options present on the page select the blank
library.
 After opening library page we select different kind of
components and use them according to there
mechanism.
 And at the end we simulate the circuit and scope is
needed to the graph of following functions or
charactristics of this.
Transfer function:

A function that algebraically relates a system's output to its input. This function
will allow separation of the input, system, and output into three separate and
distinct parts, unlike the differential equation.
Theory of this experiment:
In this experiment, we formally apply the transfer function to the mathematical
modeling of electric circuits including passive networks and operational
amplifier circuits.
In next experiments, we will cover mechanical and electromechanical systems.
Equivalent circuits for the electric networks that we work with first consist of
three passive linear components: resistors, capacitors, and inductors. We now
combine electrical components into circuits, decide on the input and output,
and find the transfer function.
Circuit diagram:
Graph of following circuit:

Step Response:
 Different step of following reponse of amplifier circuit:
 First go to the analysis tab and click on the option of
control system.
 Then click on linear analysis.
 A window open with different options.
 Select the step option.
 A graph shown on the screen of step response.

Equation:
 On matlab command window it also have different steps to follow:
 After opening linear analysis window.
 At left side of window a name present of following graph.
 We have to drag this on upper tab.
 After this go to matlab command window.
 And write a command that is
<< tf(name)
 Then enter.
LAB TASK NO# 04
Find the transfer function, G(s) = VL(s)/V(s), for the given
circuit given
OBECTVE:
Draw circuit diagram and check response on graph and also find its
transfer function.
Circuit diagram:

Graph of given circuit:


 In this step we can also change the response of required circuit due to
change in values of components.
 Scope is used to show the properties of circuits on graph.
Step response:
Transfer equation:
LAB TASK NO# 05
Objective:

Circuit diagram:

Graph response:
Step Response:
Transfer equation:
LAB TASK NO# 06
Objective:

Circuit diagram:

Graph:
Step response:
Tranfer equation:

S-ar putea să vă placă și