Intro to Matlab Rogelio Long September 3, 2013. How to access MyDesktop https://mydesktop.utep.edu/vpn/index.html Log in with your utep id and password.

Slides:



Advertisements
Similar presentations
Lecture 5.
Advertisements

Introduction to Matlab
MATLAB - Basics Centro de Informática Universidade Federal de Pernambuco Aprendizagem de Máquina – IN1102 Arley Ristar –
C ENTER FOR I NTEGRATED R ESEARCH C OMPUTING MATLAB
Dr. Jie Zou PHY Welcome to PHY 3320 Computational Methods in Physics and Engineering.
Intro to Matlab 1.Vectors, matrices, and arithmetic 2.Plotting 3.Flow Constructs 4.Other Useful Things Can be found at:
Introduction to MATLAB
Arithmetic Operations on Matrices. 1. Definition of Matrix 2. Column, Row and Square Matrix 3. Addition and Subtraction of Matrices 4. Multiplying Row.
An Introduction to Scilab Tsing Nam Kiu 丁南僑 Department of Mathematics The University of Hong Kong 2009 January 7.
1 Introduction to MATLAB MATLAB is all of the following: 1.Computational environment 2.Plotting software 3.Programming language Typical applications: 1.Calculations.
Chapter 10 Review: Matrix Algebra
Chapter 5. Loops are common in most programming languages Plus side: Are very fast (in other languages) & easy to understand Negative side: Require a.
MATLAB Basics With a brief review of linear algebra by Lanyi Xu modified by D.G.E. Robertson.
MATLAB INTRO CONTROL LAB1  The Environment  The command prompt Getting Help : e.g help sin, lookfor cos Variables Vectors, Matrices, and Linear Algebra.
1 M ATLAB Short Course. History of Calculator 2 3 Introduction to Matlab Matlab is short for Matrix Laboratory Matlab is also a programming language.
Introduction to MATLAB January 18, 2008 Steve Gu Reference: Eta Kappa Nu, UCLA Iota Gamma Chapter, Introduction to MATLAB,
Introduction to Matlab 1. Outline: What is Matlab? Matlab Screen Variables, array, matrix, indexing Operators Plotting Flow Control Using of M-File Writing.
Introduction to MATLAB
Math 15 Lecture 7 University of California, Merced Scilab A “Very” Short Introduction.
CSE123 Lecture 5 Arrays and Array Operations. Definitions Scalars: Variables that represent single numbers. Note that complex numbers are also scalars,
Array Addition  Two arrays can be added if and only if both arrays have exactly the same dimensions.  Assuming the dimension requirement is satisfied,
Introduction to MATLAB CBE 502 Mathematical Methods of Engineering Analysis.
Matlab Programming, part 1 M-files It is generally more convenient to program in Matlab using m-files, ascii text files containing a set of Matlab commands.
INTRODUCTION TO MATLAB LAB# 01
1 Lab 2 of COMP 319 Lab tutor : Shenghua ZHONG Lab 2: Sep. 28, 2011 Data and File in Matlab.
Vectors and Matrices In MATLAB a vector can be defined as row vector or as a column vector. A vector of length n can be visualized as matrix of size 1xn.
CDA6530: Performance Models of Computers and Networks Chapter 4: Using Matlab for Performance Analysis and Simulation TexPoint fonts used in EMF. Read.
MATLAB 程式設計 Learning Linear Algebra 方煒 台大生機系. MATLAB 程式設計 Vector Products, Dot and Cross a=[1,2,3];b=[3,2,1]; C=a*b D=a.*b E=dot(a,b) F=cross(a,b)
Introduction to MATLAB Session 1 Simopekka Vänskä, THL 2010.
ME6104: CAD. Module 4. ME6104: CAD. Module 4. Systems Realization Laboratory Module 4 Matlab ME 6104 – Fundamentals of Computer-Aided Design.
OUTLINE Overview Numbers, variables and similar in Matlab
MA/CS 375 Fall 2002 Lecture 3. Example 2 A is a matrix with 3 rows and 2 columns.
Introduction to Matlab By E. Noura Semary. Contents MATLAB Environment  Command window, Workspace, Path window, Editor window,and Figure window) Basic.
CS 170 – INTRO TO SCIENTIFIC AND ENGINEERING PROGRAMMING.
MATLAB Lecture Two Tuesday 5 July Chapter 3.
Computer Simulation Lab Electrical and Computer Engineering Department SUNY – New Paltz SUNY-New Paltz “Lecture 2”
Introduction to Matlab Part II 1Daniel Baur / Introduction to Matlab Part II Daniel Baur / Michael Sokolov ETH Zurich, Institut für Chemie- und Bioingenieurwissenschaften.
Programming with Matlab Day 2: More about Loops, Vectors and Matrices.
Introduction to Matlab Electromagnetic Theory LAB by Engr. Mian Shahzad Iqbal.
Introduction to MATLAB Session 2 Simopekka Vänskä, THL Department of Mathematics and Statistics University of Helsinki 2010.
Introduction to MATLAB 1.Basic functions 2.Vectors, matrices, and arithmetic 3.Flow Constructs (Loops, If, etc) 4.Create M-files 5.Plotting.
MT411 Robotic Engineering Asian Institution of Technology (AIT) Chapter 1 Introduction to Matrix Narong Aphiratsakun, D.Eng.
CS 170 – INTRO TO SCIENTIFIC AND ENGINEERING PROGRAMMING.
MA/CS 375 Fall 2002 Lecture 2. Motivation for Suffering All This Math and Stuff Try the Actor demo from
Intro to Matlab Yipei Wang & Qihui Li {yipeiw,
Matlab Tutorial Iman Moazzen First Session – September 11, 2013.
Introduction to Matlab Engr. Mian Shahzad Iqbal LAB NO.2
CS100A, Fall 1998, Lecture 201 CS100A, Fall 1998 Lecture 20, Tuesday Nov 10 More Matlab Concepts: plotting (cont.) 2-D arrays Control structures: while,
전자장 1 실험 - Matlab 사용법 - Photonic Systems Laboratory School of EE, Seoul National University Photonic Systems Lab School of EECS, S.N.U.
Outline What is MATLAB MATLAB desktop Variables, Vectors and Matrices Matrix operations Array operations Built-in functions: Scalar, Vector, Matrix Data.
Jake Blanchard University of Wisconsin Spring 2006.
Matrix Mayhem: Outline
Tutorial on Matlab Basics
Introduction to MATLAB
Introduction to MATLAB
TexPoint fonts used in EMF.
Seminar 1 for DCSP Using Matlab.
MATLAB DENC 2533 ECADD LAB 9.
Introduction To MATLAB
StatLab Matlab Workshop
بسم الله الرّحمن الرّحيم
آموزش مقدماتی نرم افزار MATLAB
CS 175 Project in AI Discussion -- matlab
Introduction to Matlab
Vectors, matrices, and arithmetic
Vectors and Matrices In MATLAB a vector can be defined as row vector or as a column vector. A vector of length n can be visualized as matrix of size 1xn.
Announcements P3 due today
How to Use MATLAB A Brief Introduction.
-seminar 1 for digital signal processing
Arrays in Matlab UC Berkeley Fall 2004, E Copyright 2005, Andy Packard
Presentation transcript:

Intro to Matlab Rogelio Long September 3, 2013

How to access MyDesktop Log in with your utep id and password Proceed/Install Citrix(wait for the DL)/Continue

Why use Matlab? Pros Easy to learn Many built in functions that you may otherwise have to find libraries for Easy to program Cons Not free

An expensive calculator Basic numerical operations: +,-,*,/,^ Don’t have to declare a data type Inf Nan Complex ex i

Some useful functions Sin, cos, tan, acos, asin, atan Sqrt, exp,log,log10 Floor, ceil, sign, rem,mod Sum, max, min find

Vectors a =[2 12 5] row vector b =[3+ 2 5] c =[A 2*B] d= [5;3;7] column vector e = 1:4 f=2:2:8

Matrices A = [2,4;5,1] B = [1:4;5:8] C = zeros(3,3) (all zeros) D = ones(4,2) (all ones) E = rand(2,2) (random number between 0-1) F = eye(3) (identity matrix)

Extracting a value from a Matrix/Vector a(2)=? c(1:2:5)=? A(1,2) = ? (outputs the value in row 1 column 2) A(3) = ? (outputs the value at index 3 column major) A(2,:) = ? (outputs row 2) A(:,2) = ? (outputs column 2)

Logicals true =1 False =0 ==,~=,>, =,<= And & Or |

Matrix operations A’ (Transpose ) A^-1, inv(A) (Inverse ) eig(A) (Eigen value ) norm(A) (Norm of a matrix ) diag(A) (extracts the diagonal of a matrix) diag(a) (turns a array into a diagonal matrix) diag(diag(A))(turns the diagonal of a matrix into a diagonal matrix)

Size of a matrix/array Size(A) (outputs [num row, num columns]) Length(a) (outputs length of an array)

Neat matrix building A = [1:3;4:6;7:9] B = [diag(diag(A)) A;A' rand(3,3)] B(4,4)=12 B(8,9)=3 (set a value out of bounds for matrix B) C = [B b] (adds array b to matrix B)

Matrix/vector arithmetic A+B A-B A*B (assuming A & B could bemultiplied) A/B (this is like A*inv(B)) A.*B A./B A^x A.^x Ax = b  x = inv(A)*b or A\b

Formats format short “ “long “ “ short e “ “ long e

Creating a script/function File/new/script F5 save&run File/new/function function [ output_args ] = foo( input_args ) foo(x) (how to call a function)

loops for i=1:2:11 …. end while test is true …. End if true …. else …. end Break (ends the deepest loop you are in)

Printing output disp(X) disp(‘some words’) fprintf(‘some words %5.3d \n’, X)

Plots x = linspace(0,2*pi, 100) y = sin(x) plot(x,y) title(‘something”) xlabel(‘x’) ylabel(‘y’)

Plots color -y,m,c,r,g,b,w,b line styles -,o,x,+,-,*,:,-.,-- plot(…….,‘LineWidth’,number…….,’) grid hold on hold off

Viewing a matrix Imagesc(B); colorbar Axis equal tight xa = linspace(-1,1,100); ya = linspace(-1,1,100); [X,Y] = meshgrid(xa,ya); A = (X.^2 + Y.^2)<=0.75

3D plots [X,Y] = meshgrid(-2:.1:2,-2:.1:2); Z = sqrt(X.^2 + Y.^2) Z = -X.*Y.*exp(-2*(X.^2+Y.^2)); Mesh(X,Y,Z) Contour(X,Y,Z)

Other stuff diary on diary off diary name (sets a name to the diary file) Help feature demo

Exercise fibonacci Create script that calls a function