MA/CS 375 Fall 2003 Lecture 3. .* Multiplication We can use the.* operator to perform multiplication entry by entry of two matrices:

Slides:



Advertisements
Similar presentations
15. Python - Modules A module allows you to logically organize your Python code. Grouping related code into a module makes the code easier to understand.
Advertisements

Perkovic, Chapter 7 Functions revisited Python Namespaces
Lecture 5.
Introduction to Matlab
Introduction to Matlab Workshop Matthew Johnson, Economics October 17, /13/20151.
Functions in MatLab Create a new folder on your Z:drive called MatLab_Class24 Start MatLab and change your current directory to MatLab_Class24 Topics:
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 19P. 1Winter Quarter MATLAB: Script and.
General Computer Science for Engineers CISC 106 Lecture 02 James Atlas Computer and Information Sciences 6/10/2009.
MATLAB ME1107 Y Yan Reference: MATLAB for Engineers by Holly Moore (Pearson Prentice Hall)
General Computer Science for Engineers CISC 106 Lecture 08 Dr. John Cavazos Computer and Information Sciences 2/27/2009.
FORTRAN.  Fortran or FORmula TRANslation was developed in the 1950's by IBM as an alternative to Assembly Language. First successfull high level language.
1 Python Chapter 2 © Samuel Marateck, After you install the compiler, an icon labeled IDLE (Python GUI) will appear on the screen. If you click.
Introduction to MATLAB ENGR 1187 MATLAB 1. Programming In The Real World Programming is a powerful tool for solving problems in every day industry settings.
Introduction to programming in MATLAB MATLAB can be thought of as an super-powerful graphing calculator Remember the TI-83 from calculus? With many more.
What is MATLAB ? MATrix LABratory –Originally, it was a front-end to FORTRAN matrix routines developed in the U. of New Mexico and Stanford –Today.
4. Week 04.March Use of M-File Editor/Debugger: text editor, debugger; editor works with file types in addition to.m (MATLAB “m-files”)
Python  By: Ben Blake, Andrew Dzambo, Paul Flanagan.
Chapter 5. Loops are common in most programming languages Plus side: Are very fast (in other languages) & easy to understand Negative side: Require a.
Nonparametric Econometrics1 Intro to Matlab for Data Analysis and Statistical Modeling.
Lecture 4 MATLAB Windows Arithmetic Operators Maintenance Functions
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.
Math 15 Lecture 7 University of California, Merced Scilab A “Very” Short Introduction.
Recap Graphic Window Edit Window Start Button Matrices in MATLAB Scalar Operations Order of Operations Array Operations Matrix Addition Matrix Multiplication.
1 Week 3: Vectors and Matrices (Part III) READING: 2.2 – 2.4 EECS Introduction to Computing for the Physical Sciences.
Modules and Decomposition UW CSE 190p Summer 2012 download examples from the calendar.
MATLAB An Introduction to MATLAB (Matrix Laboratory) 1.
Computational Methods of Scientific Programming Lecturers Thomas A Herring, Room A, Chris Hill, Room ,
Introduction to Engineering MATLAB – 6 Script Files - 1 Agenda Script files.
Numerical Computation Lecture 2: Introduction to Matlab Programming United International College.
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.
What is MATLAB? MATLAB is one of a number of commercially available, sophisticated mathematical computation tools. Others include Maple Mathematica MathCad.
Introduction to Matlab Module #2 Page 1 Introduction to Matlab Module #2 – Arrays Topics 1.Numeric arrays (creation, addressing, sizes) 2.Element-by-Element.
10/24/20151 Chapter 2 Review: MATLAB Environment Introduction to MATLAB 7 Engineering 161.
MATLAB Harri Saarnisaari, Part of Simulations and Tools for Telecommunication Course.
Flow Control and Functions ● Script files ● If's and For's ● Basics of writing functions ● Checking input arguments ● Variable input arguments ● Output.
Advanced Topics- Functions Introduction to MATLAB 7 Engineering 161.
What does C store? >>A = [1 2 3] >>B = [1 1] >>[C,D]=meshgrid(A,B) c) a) d) b)
Scientific Computing Introduction to Matlab Programming.
ME6104: CAD. Module 4. ME6104: CAD. Module 4. Systems Realization Laboratory Module 4 Matlab ME 6104 – Fundamentals of Computer-Aided Design.
Chapter 6 Review: User Defined Functions Introduction to MATLAB 7 Engineering 161.
MA/CS 375 Fall 2002 Lecture 3. Example 2 A is a matrix with 3 rows and 2 columns.
© David Kirk/NVIDIA and Wen-mei W. Hwu, ECE498AL, University of Illinois, Urbana-Champaign 1 ECE498AL Lecture 4: CUDA Threads – Part 2.
Getting Started with MATLAB (part 3) 1. Algebra, 2. Trig 3. The keyword ans 4. Clean up and suppress output: finalizing the software’s presentation 1.
CS 170 – INTRO TO SCIENTIFIC AND ENGINEERING PROGRAMMING.
Recap Saving Plots Summary of Chapter 5 Introduction of Chapter 6.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Introduction to MATLAB 7 for Engineers William J. Palm.
MATLAB Lecture Two Tuesday 5 July Chapter 3.
Computer Simulation Lab Electrical and Computer Engineering Department SUNY – New Paltz SUNY-New Paltz “Lecture 2”
MA/CS 375 Fall 2002 Lecture Summary Week 1  Week 7.
Lecture 20: Choosing the Right Tool for the Job. What is MATLAB? MATLAB is one of a number of commercially available, sophisticated mathematical computation.
Lecture 26: Reusable Methods: Enviable Sloth. Creating Function M-files User defined functions are stored as M- files To use them, they must be in the.
Introduction to Matlab  Matlab is a software package for technical computation.  Matlab allows you to solve many numerical problems including - arrays.
Parallel Programming Basics  Things we need to consider:  Control  Synchronization  Communication  Parallel programming languages offer different.
Introduction to MATLAB 1.Basic functions 2.Vectors, matrices, and arithmetic 3.Flow Constructs (Loops, If, etc) 4.Create M-files 5.Plotting.
MA/CS 375 Fall 2002 Lecture 2. Motivation for Suffering All This Math and Stuff Try the Actor demo from
MATLAB Constants, Variables & Expression Nafees Ahmed Asstt. Professor, EE Deptt DIT, DehraDun.
Matlab Tutorial Iman Moazzen First Session – September 11, 2013.
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.
Jake Blanchard University of Wisconsin Spring 2006.
Release Numbers MATLAB is updated regularly
L – Modeling and Simulating Social Systems with MATLAB
INTRODUCTION TO BASIC MATLAB
MATLAB DENC 2533 ECADD LAB 9.
User Defined Functions
MATH 493 Introduction to MATLAB
Use of Mathematics using Technology (Maltlab)
Introduction to Matlab
Introduction to Matlab
Presentation transcript:

MA/CS 375 Fall 2003 Lecture 3

.* Multiplication We can use the.* operator to perform multiplication entry by entry of two matrices:

./ Division We can use the./ operator to perform division with the entries of A in the numerator and entries of B in the denominator.

.\ Division We can use the.\ operator to perform division with the entries of A in the denominator and entries of B in the numerator.

.^ Power We can use the.^ operator to compute:

Dot Operators and Matrices We can also use the dot versions of multiplication, division… on matrices

Quick Test What does C equal??

Solution: Recall: even though we changed B on the last step, C does not change!!!.

Functions in Matlab Matlab has a number of built-in functions: –cos, sin, tan, acos, asin, atan –cosh, sinh, tanh, acosh, asinh, atanh –exp, log, sqrt They all take matrices as arguments and return matrices of the same dimensions. e.g. cos([1 2 3]) For other functions type: > help matlab\elfun

Example of Function of Vector

Special Random Matrix Function Say I want to create a 3 by 2 matrix with random entries, with each entry between 0 and 1: What will happen if I run this again?

Customizing Matlab

Changing Your “Working” Directory First make a directory you want to do store your results in on the Desktop Click on the … in the box next to the “Current Directory”

cont Next click on your directory (which should be somewhere on the desktop) For following lectures bring a 3.5 inch floppy diskette

Matlab is Yours to Command It is very likely that you will need to use the same string of commands, over and over. We can create an M-File which contains a set of commands which will be executed. – e.g. create a script file mygrid.m containing: x1d = linspace( 0, 1, Npts); y1d = linspace( 0, 1, Npts); [x2d, y2d] = meshgrid( x1d, y1d);

Creating a Matlab M-File Click on: File/New/M-File

Editing a Matlab M-File

Saving Your M-File Make sure you save it in your “Working Directory”

Calling Your Own Script

Custom-Made Matlab Functions function [ radius, theta] = myfunc( x, y) % this is a comment, just like // in C++ % now create and evaluate theta (in radians) theta = atan2(y,x); % now create and evaluate radius radius = sqrt( x.^2 + y.^2); Say we wish to create a function that turns Cartesian coordinates into polar coordinates. We can create a text file with the following text. It can be called like any built in function.

Custom Built Function For Matlab Make sure you that the Matlab current directory is set to the directory containing myfunc.m the arguments to myfunc could also have been matrices – leading to two matrices being output.

Constraints on Custom-Built Matlab Functions Matlab follows similar scope rules to C. Without resorting to the Matlab command global the only variables available inside the function are those passed as arguments to the function, or created inside the function. Just in case you are thinking about using global – I consider it poor programming…

Loops in Matlab

Much like C or Fortran we can use a loop syntax to repeat a sequence of commands. HOWEVER, Matlab is an interpreted language and as such is not efficient in executing loop operations. In other words, using loops in Matlab is very slow!.

Loops in Matlab One variant of Matlab loop syntax is: for var=start:end commands; end

Example of a Matlab Loop Say I want to add the numbers from 1 to 10, without using the Matlab intrinsic sum.

Summary of Lectures 2 and 3 We have learnt how to: – run matlab – create matrices (and hence vectors) – set the entries of a matrix – add two matrices – subtract two matrices – multiply two matrices – loops – creating custom functions..