Introduction to Matlab Οικονομίδης Δημήτρης

Slides:



Advertisements
Similar presentations
MATLAB – A Computational Methods By Rohit Khokher Department of Computer Science, Sharda University, Greater Noida, India MATLAB – A Computational Methods.
Advertisements

StatLab Workshop Yale University Maximiliano Appendino, Economics October 18 th, 2013.
Introduction to M ATLAB Programming Ian Brooks Institute for Climate & Atmospheric Science School of Earth & Environment
Introduction to Matlab
Introduction to MATLAB
Introduction to Matlab Workshop Matthew Johnson, Economics October 17, /13/20151.
Introduction to MATLAB for Biomedical Engineering BME 1008 Introduction to Biomedical Engineering FIU, Spring 2015 Lesson 2: Element-wise vs. matrix operations.
Introduction to Matlab EE 2303 Lab. MATLAB stands for “Matrix Laboratory” APPLICATIONS OF MATLAB:  Mathematical Calculations  Data Analysis & Visualization.
Introduction to Matlab By: Dr. Maher O. EL-Ghossain.
Exam #3 Review: Comprehensive Exam Class 14.2 Palm Matlab Book Ch. 1-5.
Getting started with Matlab Numerical Methods Appendix B help/techdoc/learn_matlab/learn_matlab.html.
Introduction to Matlab Jianguo Wang CSSCR September 2009.
An Introduction to Scilab Tsing Nam Kiu 丁南僑 Department of Mathematics The University of Hong Kong 2009 January 7.
259 Lecture 15 Introduction to MATLAB. 2 What is MATLAB?  MATLAB, which stands for “MATrix LABoratory” is a high- performance language for technical.
1 Statistical Computing in MATLAB AMS 597 Ling Leng.
Martin Ellison University of Warwick and CEPR Bank of England, December 2005 Introduction to MATLAB.
Nonparametric Econometrics1 Intro to Matlab for Data Analysis and Statistical Modeling.
Introduction to MATLAB Zongqiang Liao Research Computing Group UNC-Chapel Hill.
Introduction to Matlab 1. Outline: What is Matlab? Matlab Screen Variables, array, matrix, indexing Operators Plotting Flow Control Using of M-File Writing.
Eng Advanced Marine Vehicles Todays agenda: Lab tomorrow at 2pm (structures lab) ‏ Advanced Marine Party Introduction to Matlab.
ELG 3120 Signal and System Analysis 1 Introduction to MATLAB TAs Wei Zhang Ozgur Ekici (Section A)(Section B) ELG 3120 Lab Tutorial 1.
1 Lab of COMP 406 Teaching Assistant: Pei-Yuan Zhou Contact: Lab 1: 12 Sep., 2014 Introduction of Matlab (I)
MEGN 536 – Computational Biomechanics MATLAB: Getting Started Prof. Anthony J. Petrella Computational Biomechanics Group.
Yasser F. O. Mohammad Approximations and Round-off Errors.
A Brief Introduction to Matlab Laila Guessous Dept. of Mechanical Engineering Oakland University.
Eng Ship Structures 1 Introduction to Matlab.
INTRODUCTION TO MATLAB LAB# 01
1 Computer Programming (ECGD2102 ) Using MATLAB Instructor: Eng. Eman Al.Swaity Lecture (1): Introduction.
Matlab Basics Tutorial. Vectors Let's start off by creating something simple, like a vector. Enter each element of the vector (separated by a space) between.
Chapter 1: Getting Started with MATLAB MATLAB for Scientist and Engineers Using Symbolic Toolbox.
1 Lab 2 of COMP 319 Lab tutor : Shenghua ZHONG Lab 2: Sep. 28, 2011 Data and File in Matlab.
CMPS 1371 Introduction to Computing for Engineers MatLab.
10/24/20151 Chapter 2 Review: MATLAB Environment Introduction to MATLAB 7 Engineering 161.
Matlab The language of Technical computing Mr. D. Suresh Assistant Professor, Dept. of CSE, PSNA CET, Dindigul.
Matlab 14.html Cost: $100 Available in labs on Windows and Unix machines.
Introduction to Matlab. Outline:  What is Matlab? Matlab Screen Variables, array, matrix, indexing Operators (Arithmetic, relational, logical ) Display.
Master in Optical Fiber Communications and Photonic Technologies Foundations of Digital Transmission - Fall quarter Introduction to Matlab.
Introduction to Matlab. What is Matlab? A software environment for interactive numerical computations Examples:  Matrix computations and linear algebra.
Matlab Screen  Command Window  type commands  Current Directory  View folders and m-files  Workspace  View program variables  Double click on a.
Introduction to Matlab By E. Noura Semary. Contents MATLAB Environment  Command window, Workspace, Path window, Editor window,and Figure window) Basic.
Computer Simulation Lab Electrical and Computer Engineering Department SUNY – New Paltz SUNY-New Paltz “Lecture 2”
MATLAB Tutorial EE313 Signals and Systems Created: Thursday Jan 25, 2007 Rayyan Jaber Modified by: Jeff Andrews.
A simple classification problem Extract attributes Pattern Pattern recognition decision x C1 C2.
1 Introduction to Matlab-2 Laboratoire Mathématiques, Informatique et Applications.
Introduction to Matlab  Matlab is a software package for technical computation.  Matlab allows you to solve many numerical problems including - arrays.
Introduction to Matlab
Introduction to MATLAB Zongqiang Liao Research Computing Group UNC-Chapel Hill.
Introduction to MATLAB 1.Basic functions 2.Vectors, matrices, and arithmetic 3.Flow Constructs (Loops, If, etc) 4.Create M-files 5.Plotting.
Introduction to Matlab Engr. Mian Shahzad Iqbal LAB NO.2
Matlab Tutorial (material available at 1 Dr. Jim Martin Associate Professor School of Computing.
MATLAB (Matrix Algebra laboratory), distributed by The MathWorks, is a technical computing environment for high performance numeric computation and.
전자장 1 실험 - Matlab 사용법 - Photonic Systems Laboratory School of EE, Seoul National University Photonic Systems Lab School of EECS, S.N.U.
1 Introduction to Matlab. 2 What is Matlab? Matlab is basically a high level language which has many specialized toolboxes for making things easier for.
Outline What is MATLAB MATLAB desktop Variables, Vectors and Matrices Matrix operations Array operations Built-in functions: Scalar, Vector, Matrix Data.
MATLAB ……………….matrix laboratory. Bhushan D Patil PhD Research Scholar Department of Electrical Engineering Indian Institute of Technology, Bombay Powai,
Introduction to Matlab. Outline:  What is Matlab? Matlab Screen Variables, array, matrix, indexing Operators.
MATLAB: How do you work with data to solve problems?
Matlab Programming for Engineers
Introduction to MATLAB
Introduction to Mat lab
Statistical Computing in MATLAB
MATLAB Introduction Main Features Simple programming rules
INTRODUCTION TO BASIC MATLAB
MATLAB DENC 2533 ECADD LAB 9.
Introduction to Matlab
Matlab Workshop 9/22/2018.
StatLab Matlab Workshop
Use of Mathematics using Technology (Maltlab)
StatLab Workshop: Intro to Matlab for Data Analysis and Statistical Modeling 11/29/2018.
MATLAB Introduction Main Features Simple programming rules
Presentation transcript:

Introduction to Matlab Οικονομίδης Δημήτρης

Desktop Tools (Matlab v6) Command Window –type commands Workspace –view program variables –clear to clear –double click on a variable to see it in the Array Editor Command History –view past commands –save a whole session using diary Launch Pad –access tools, demos and documentation

Matlab Files (.m) Use predefined functions or write your own functions Reside on the current directory or the search path –add with File/Set Path Use the Editor/Debugger to edit, run

Matrices a vector x = [ ] x = a matrix x = [1 2 3; 5 1 4; ] x = transpose y = x.’ y =

Matrices x(i,j) subscription whole row whole column y=x(2,3) y = 4 y=x(3,:) y = y=x(:,2) y = 2 1 2

Operators (arithmetic) +addition -subtraction *multiplication /division ^power ‘complex conjugate transpose.*element-by-element mult./element-by-element div.^element-by-element power.‘transpose

Operators (relational, logical) ==equal ~=not equal <less than <=less than or equal >greater than >=greater than or equal &AND |OR ~NOT pi … jimaginary unit, isame as j

Generating Vectors from functions zeros(M,N)MxN matrix of zeros ones(M,N)MxN matrix of ones rand(M,N)MxN matrix of uniformly distributed random numbers on (0,1) x = zeros(1,3) x = x = ones(1,3) x = x = rand(1,3) x =

Operators [ ]concatenation ( )subscription x = [ zeros(1,3) ones(1,2) ] x = x = [ ] x = y = x(2) y = 3 y = x(2:4) y = 3 5 7

Matlab Graphics x = 0:pi/100:2*pi; y = sin(x); plot(x,y) xlabel('x = 0:2\pi') ylabel('Sine of x') title('Plot of the Sine Function')

Multiple Graphs t = 0:pi/100:2*pi; y1=sin(t); y2=sin(t+pi/2); plot(t,y1,t,y2) grid on

Multiple Plots t = 0:pi/100:2*pi; y1=sin(t); y2=sin(t+pi/2); subplot(2,2,1) plot(t,y1) subplot(2,2,2) plot(t,y2)

Graph Functions (summary) plotlinear plot stemdiscrete plot gridadd grid lines xlabeladd X-axis label ylabel add Y-axis label titleadd graph title subplotdivide figure window figurecreate new figure window pausewait for user response

Math Functions Elementary functions (sin, cos, sqrt, abs, exp, log10, round) –type help elfun Advanced functions (bessel, beta, gamma, erf) –type help specfun –type help elmat

Functions function f=myfunction(x,y) f=x+y; save it in myfunction.m call it with y=myfunction(x,y)

Flow Control if A > B 'greater' elseif A < B 'less' else 'equal' end for x = 1:10 r(x) = x; end if statement switch statement for loops while loops continue statement break statement

Miscellaneous Loading data from a file –load myfile.dat Suppressing Output –x = [ ];

Getting Help Using the Help Browser (.html,.pdf) –View getstart.pdf, graphg.pdf, using_ml.pdf Type –help –help function, e.g. help plot Running demos –type demos –type help demos

Random Numbers x=rand(100,1); stem(x); hist(x,100)

Coin Tosses Simulate the outcomes of 100 fair coin tosses x=rand(100,1); p=sum(x<0.5)/100 p = Simulate the outcomes of 1000 fair coin tosses x=rand(1000,1); p=sum(x<0.5)/1000 p =

Coin Tosses Simulate the outcomes of 1000 biased coin tosses with p[Head]=0.4 x=rand(1000,1); p=sum(x<0.4)/1000 p =

Sum of Two Dies Simulate observations of the sum of two fair dies

Sum of Two Dies Simulate observations of the sum of two fair dies x1=floor(6*rand(10000,1)+1); x2=floor(6*rand(10000,1)+1); y=x1+x2; sum(y==2)/10000ans = p[2]= sum(y==3)/10000ans = p[3]= sum(y==4)/10000ans = p[4]= sum(y==5)/10000ans = p[5]= sum(y==6)/10000ans = p[6]= sum(y==7)/10000ans = p[7]= sum(y==8)/10000ans = p[8]= sum(y==9)/10000ans = p[9]= sum(y==10)/10000ans = p[10]= sum(y==11)/10000ans = p[11]= sum(y==12)/10000ans = p[12]=0.0278

Sum of Two Dies for i=2:12 z(i)=sum(y==i)/10000 end bar(z)

Bernoulli Trials-Binomial Distribution k=0:20; y=binopdf(k,20,0.5); stem(k,y) Bernoulli1720 k=0:20; y=binopdf(k,20,0.2); stem(k,y)

Combinatorics Permutations:n objects Permutations:choose k objects from n (hint: fill 2 spaces on a bookshelf with books chosen from 5 available books) Combinations:choose k objects from n without regard to the order (hint: make a committee of 2 people chosen from a group of 5 people)