0% found this document useful (0 votes)
87 views27 pages

Day1 Final

This document provides an introduction to MATLAB. It discusses that MATLAB is a matrix laboratory for doing matrix operations and contains thousands of built-in functions. It then demonstrates how to define variables, matrices, and use basic functions in MATLAB such as addition and defining matrices using colons. The document also discusses using MATLAB for applications such as system modeling, polynomials, and neural networks by representing these concepts using matrices.

Uploaded by

Rabinsa Yadav
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
87 views27 pages

Day1 Final

This document provides an introduction to MATLAB. It discusses that MATLAB is a matrix laboratory for doing matrix operations and contains thousands of built-in functions. It then demonstrates how to define variables, matrices, and use basic functions in MATLAB such as addition and defining matrices using colons. The document also discusses using MATLAB for applications such as system modeling, polynomials, and neural networks by representing these concepts using matrices.

Uploaded by

Rabinsa Yadav
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 27

Abhishek Kr Gupta

Department of Electrical Engineering Indian Institute of Technology Kanpur (IIT K)

To MATLAB

What is MATLAB?
MATrix LABoratory Does Matrix Operations Thousands of inbuilt functions ToolBoxes GUIS A programming Language
A complete software package Simulink Modeling tools EDA tools

LAYOUT

A Simple Start:
Add two Variables
No definitions needed, no classes needed On command window type:
>>A=5; >>B=4; >>C=A+B;

Type C to see the value

C=9

Editors:
Editors are used to store codes
Code is nothing but just a set of lines M Files are used in MATLAB having extension .m

Types: Script File

Set of code lines A code implementing some functions like sin, cos exp (they are inbuilt)

Function File

Defining Matrices:
Just write all the entries separated by the space or

comma and enclosed in a bracket [] A=[1 2 3 2] Or A=[1,2,3,2] For column matrix, put semicolon ; in between A=[1;2;3;2]

Importance of Matrix:
Not just as a transformation Also set of data or samples Electrical Signals Performance outputs Images Also as model representation Polynomials Transfer functions Neural Networks

Polynomials:

These are some of the Polynomials you have Come across.

Polynomials in MATLAB
A polynomial can be represented in the form of

coefficients. For example, if you want to write

You have to just write [1 2 2 5] Each number represents the value of coefficients.

This will be represented as [1 0 2 5]

System Modeling using Matrix:


Recall the well known example of LCR circuit:
O U T P U T

I N P U T

Output across resistor V0=R.i


Modeled using matrix as

Similarly a Motor System


A Motor Speed System

We write its state equations:

Transfer Functions

Polynomials [K2] [1 2 K2]

Neural Systems
Systems modeled as a set of transformation with

neurons as Weight matrixes

Problems with Other Programming Languages


No Matrix operations
For Loops everywhere Lots of unnecessary lines

with MALTAB

Define Matrixs
Mix , and ; to make 2 D matrix

A=[1 2 3 2; 1 3 2 1;2 3 6 1] Make A 1 to 10 Matrix A=[1 2 3 4 5 6 7 8 9 10]; Make 1 to 100


Tired?? Use colon :Which mean TO

A=[1:100];

Colon (:) = TO
[1:4]

Gives a vector from 1 to 4

1234 [1:0.5:4] Gives a vector from 1 to 4 with step 0.5 1 1.5 2 2.5 3 3.5 4 [0:0.1:2*pi] Gives a vector containing 0 to 2

Operators
Matrix Operators Y=A^2 Y=A^B
X=A*B

Dot Operators Y=A.^2 X=A.*B Y=A.^B

Functions Subscripting

Typical MATLAB functions


Mathematical sqrt sin,cos,tan Log, exp Creation ones zeros eye Rand Information size length

Typical MATLAB functions


Matrix Operations sum diag transpose or inv det eig fliplr reshape flipud rot90 repmat

Concatenation of Matrices
Suppose A, B, C are matrices
If we write [A B] or [A,B] If we write [A;B]

Similarly [A B C] and [A;B;C]


[[A B];C]

Crete a with size 4x5


With elements from 3to7\

uGP

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy