Introduction to MATLAB

Slides:



Advertisements
Similar presentations
Lab # 03- SS Basic Graphic Commands. Lab Objectives: To understand M-files principle. To plot multiple plots on a single graph. To use different parameters.
Advertisements

Introduction to M ATLAB Programming Ian Brooks Institute for Climate & Atmospheric Science School of Earth & Environment
Plotting Selim Aksoy Bilkent University Department of Computer Engineering
Introduction to Matlab
Lecture (4) Plotting & Programming (1) Eng. Osama Talaat 1.
M AT L AB Programming: scripts & functions. Scripts It is possible to achieve a lot simply by executing one command at a time on the command line (even.
Introduction to MATLAB for Biomedical Engineering BME 1008 Introduction to Biomedical Engineering FIU, Spring 2015 Lesson 2: Element-wise vs. matrix operations.
MATLAB – What is it? Computing environment / programming language Tool for manipulating matrices Many applications, you just need to get some numbers in.
ECEN/MAE 3723 – Systems I MATLAB Lecture 1. Lecture Overview  Introduction and History  Matlab architecture  Operation basics  Visualization  Programming.
MA/CS375 Fall MA/CS 375 Fall 2002 Lecture 4.
Introduction to MATLAB Northeastern University: College of Computer and Information Science Co-op Preparation University (CPU) 10/27/2003.
Introduction to MATLAB Northeastern University: College of Computer and Information Science Co-op Preparation University (CPU) 10/22/2003.
Introduction to MATLAB Northeastern University: College of Computer and Information Science Co-op Preparation University (CPU) 10/27/2003.
Introduction to MATLAB Northeastern University: College of Computer and Information Science Co-op Preparation University (CPU) 10/22/2003.
Introduction to MATLAB Northeastern University: College of Computer and Information Science Co-op Preparation University (CPU) 10/29/2003.
Introduction to Array The fundamental unit of data in any MATLAB program is the array. 1. An array is a collection of data values organized into rows and.
MATLAB Fundamentals.
Objectives Understand what MATLAB is and why it is widely used in engineering and science Start the MATLAB program and solve simple problems in the command.
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.
Computational Methods of Scientific Programming Lecturers Thomas A Herring, Room A, Chris Hill, Room ,
INTRODUCTION TO MATLAB LAB# 01
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.
Matlab Programming for Engineers Dr. Bashir NOURI Introduction to Matlab Matlab Basics Branching Statements Loops User Defined Functions Additional Data.
Lecture 2 - Matlab Introduction CVEN 302 June 5, 2002.
Barbara/Pratik/Yu. Outline Matlab desktop M-files Variables Arrays Plots.
Matlab Screen  Command Window  type commands  Current Directory  View folders and m-files  Workspace  View program variables  Double click on a.
Introduction to Scientific Programming in MATLAB Michael McLennan Software Architect HUBzero™ Platform for Scientific Collaboration.
EGR 106 Lecture 6 2-D Plotting Graphical presentation has become the standard method to show technical information. Engineers use plots to analyze, visualize,
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 Northeastern University: College of Computer and Information Science Co-op Preparation University (CPU) 10/20/2003.
Introduction to MATLAB 1.Basic functions 2.Vectors, matrices, and arithmetic 3.Flow Constructs (Loops, If, etc) 4.Create M-files 5.Plotting.
Math 252: Math Modeling Eli Goldwyn Introduction to MATLAB.
CS100A, Fall 1998, Lecture 191 CS100A, Fall 1998 Lecture 19, Thursday Nov 05 Matlab Concepts: Matlab arrays Matlab subscripting Matlab plotting.
CS100A, Fall 1998, Lecture 201 CS100A, Fall 1998 Lecture 20, Tuesday Nov 10 More Matlab Concepts: plotting (cont.) 2-D arrays Control structures: while,
An Introduction to Programming in Matlab Emily Blumenthal
MATLAB (Matrix Algebra laboratory), distributed by The MathWorks, is a technical computing environment for high performance numeric computation and.
1-2 What is the Matlab environment? How can you create vectors ? What does the colon : operator do? How does the use of the built-in linspace function.
How to use MATLAB (using M-files) Double click this icon To start Matlab 6.5.
Creating a Plot The plot function can take one or more inputs; e.g. plot (x, y) or plot (y) Note that in the two-argument version, the vectors x and.
Release Numbers MATLAB is updated regularly
Prof. Mark Glauser Created by: David Marr
Introduction to Mat lab
Course Information Do not rely on color to distinguish curves (due to black-white printout). Use different line styles to distinguish curves (solid, dashed,
Lecture 25: Exploring data
Matrices and Arrays.
INTRODUCTION TO BASIC MATLAB
MATLAB DENC 2533 ECADD LAB 9.
Matlab Workshop 9/22/2018.
ECEN Automatic Control Systems Introduction and Control Basics
MATLAB How to use (using M-files) Double click this icon
MATH 493 Introduction to MATLAB
MATLAB How to use (using M-files) Double click this icon
Lecture 2 Introduction to MATLAB
Tutorial 2 SEG7550 Introduction to MATLAB II
MATLAB How to use (using M-files)
Introduction to MATLAB Plotting LAB 3
Introduction to MATLAB
INTRODUCTION TO MATLAB
Introduction to MATLAB
Plotting Signals in MATLAB
Introduction to MATLAB
Introduction to MATLAB
Introduction to MATLAB
244-2: MATLAB/Simulink FUNDAMENTALS
Announcements P3 due today
Introduction to Matlab
Matlab Basics Tutorial
Presentation transcript:

Introduction to MATLAB EE-589 Introduction to Neural Networks

History of MATLAB Ancestral software to MATLAB Fortran subroutines for solving linear (LINPACK) and eigenvalue (EISPACK) problems Developed primarily by Cleve Moler in the 1970’s

History of MATLAB, con’t: 2 The Mathworks, Inc. was created in 1984 The Mathworks is now responsible for development, sale, and support for MATLAB The Mathworks is located in Natick, MA The Mathworks is an employer that hires co-ops through our co-op program

MATLAB GUI Launch Pad / Toolbox Workspace Current Directory Command History Command Window

Launch Pad / Toolbox Will not be covered Launch Pad allows you to start help/demos Toolbox is for use with specialized packages (Signal Processing)

Workspace Allows access to data Area of memory managed through the Command Window Shows Name, Size (in elements), Number of Bytes and Type of Variable

Current Directory MATLAB, like Windows or UNIX, has a current directory MATLAB functions can be called from any directory Your programs (to be discussed later) are only available if the current directory is the one that they exist in

Command History Allows access to the commands used during this session, and possibly previous sessions Clicking and dragging to the Command window allows you to re-execute previous commands

Command Window Probably the most important part of the GUI Allows you to input the commands that will create variables, modify variables and even (later) execute scripts and functions you program yourself.

Save save – saves workspace variables on disk save filename stores all workspace variables in the current directory in filename.mat save filename var1 var2 ... saves only the specified workspace variables in filename.mat. Use the * wildcard to save only those variables that match the specified pattern.

Clear clear removes items from workspace, freeing up system memory Examples of syntax: clear clear name clear name1 name2 name3 ...

clc Not quite clear clc clears only the command window, and has no effect on variables in the workspace.

Load load - loads workspace variables from disk Examples of Syntax: load filename load filename X Y Z

The presence or lack of a semi-colon after a MATLAB command does not generate an error of any kind The presence of a semi-colon tells MATLAB to suppress the screen output of the command

The lack of a semi-colon will make MATLAB output the result of the command you entered One of these options is not necessarily better than the other

Declaring a variable, con’t: 3 You may now use the simple integer or float that you used like a normal number (though internally it is treated like a 1 by 1 matrix) Possible operations: +, -, / Many functions (round(), ceil(), floor())

Declaring a variable, con’t: 4 You may also make a vector rather simply The syntax is to set a variable name equal to some numbers, which are surrounded by brackets and separated by either spaces or commas Ex. A = [1 2 3 4 5]; Or A = [1,2,3,4,5];

Declaring a variable, con’t: 5 You may also declare a variable in a general fashion much more quickly Ex. A = 1:1:10 The first 1 would indicate the number to begin counting at The second 1 would be the increase each time And the count would end at 10

Declaring a variable, con’t: 6 Matrices are the primary variable type for MATLAB Matrices are declared similar to the declaration of a vector Begin with a variable name, and set it equal to a set of numbers, surrounded by brackets. Each number should be seperated by a comma or semi-colon

Declaring a variable, con’t: 7 The semi-colons in a matrix declaration indicate where the row would end Ex. A = [ 1,2;3,4] would create a matrix that looks like [ 1 2 3 4 ]

Everything is matrix

Matrix index

Manipulate matrices

Manipulate matrices

Script or function? Scripts are m-files containing MATLAB statements Functions are like any other m-file, but they accept arguments It is always recommended to name function file the same as the function name

Try to code in matrix ways

Script m-files

mesh

x=[ -10:1:10]; y = [-10:4:10]; [x, y] = meshgrid(x,y); z = x.^2 + y.^2; mesh(x,y,z); title('Mesh Ornek 3'); ylabel('Y Ekseni'); xlabel('X Ekseni'); zlabel('Z Eksen');

Plotting Several types of plots available Plot Polar Bar Hist

Color options Color options: Example: plot(temp, ‘y’); Yellow - ‘y’ Magenta - ‘m’ Cyan - ‘c’ Red - ‘r’ Green - ‘g’ Blue - ‘b’ White - ‘w’ Black - ‘k’ Example: plot(temp, ‘y’);

Line options Line styles: - solid line (default) -- dashed line : dotted line -. dash-dot line

Marker Options + - plus sign o - circle * - asterisk . - Point x - cross s - square d - diamond ^ - upward pointing triangle v - downward pointing triangle > - right pointing triangle < - left pointing triangle p - five-pointed star (pentagram) h - six-pointed star (hexagram)

Plot() (from MATLAB help) Linear 2-D plot Syntax: plot(Y) plot(X1,Y1,...) plot(X1,Y1,LineSpec,...) plot(...,'PropertyName',PropertyValue,...) h = plot(...)

Plot() con’t: 2 MATLAB defaults to plotting a blue line between points Other options exist: Different color lines Different types of lines No line at all!

Example angle = linspace(0, 2*pi, 360); x = cos(angle); y = sin(angle); plot(x,y); % it draws a circle axis('equal'); ylabel('y'); xlabel('x'); title('Pretty Circle') ; grid on

Polar() Plot polar coordinates Syntax: polar(theta,rho) polar(theta,rho,LineSpec) Theta – Angle counterclockwise from the 3 o’clock position Rho – Distance from the origin

Polar() con’t: 2 Line color, style and markings apply as they did in the example with Plot(). t = 0:.01:2*pi; polar(t,sin(2*t).*cos(2*t),'--r')

Bar() Creates a bar graph Syntax bar(Y) bar(x,Y) bar(...,width) bar(...,'style') bar(...,LineSpec)

Bar example subplot(3,1,1), bar(rand(10,5),'stacked'), colormap(cool) subplot(3,1,2), bar(0:.25:1,rand(5),1) subplot(3,1,3),bar(rand(2,3),.75,'grouped')

Hist() Creates a histogram plot Syntax: n = hist(Y) n = hist(Y,x) n = hist(Y,nbins) Example x = -4:0.1:4; y = randn(10000,1); hist(y,x)

Pie x=[.19 .22 .41 .18]; pie(x) explode = zeros(size(x)); h = pie(x, explode); textObjs = findobj(h, 'Type', 'text'); oldStr = get(textObjs, {'String'}); val = get(textObjs, {'Extent'}); oldExt = cat(1, val{:}); Names = {'P1: '; 'P2: '; 'P3: '; 'P4: '}; newStr = strcat(Names, oldStr); set (textObjs, {'String'}, newStr)

Another satisfied MATLAB user! End