Functions (subprograms)

Slides:



Advertisements
Similar presentations
Introduction to MATLAB
Advertisements

Introduction To MATLAB Programming
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.
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:
Excel Objects, User Interface, and Data Entry. ◦ Application Window  Title Bar  Menu Bar  Toolbars  Status Bar  Worksheet Window  Worksheet Input.
Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 20P. 1Winter Quarter Propulsion Lab with MATLAB Lecture 20.
EGR 106 – Week 2 – Arrays Definition, size, and terminology Construction methods Addressing and sub-arrays Some useful functions for arrays Character arrays.
Lecture 7 Sept 17 Goals: Complete Chapter 4 Chapters 5 and 6.
General Computer Science for Engineers CISC 106 Final Exam Review Dr. John Cavazos Computer and Information Sciences 05/18/2009.
EGR 106 – Week 8 Data Files & Functions Interacting with Data Files Functions – Concept – Examples and applications Textbook chapter ,
CIS 101: Computer Programming and Problem Solving Lecture 4 Usman Roshan Department of Computer Science NJIT.
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.
AN ENGINEER’S GUIDE TO MATLAB
MATLAB File Management. MATLAB User File Management Matlab provides a group of commands to manage user files. For more information, type help iofun. pwd.
DHL EasyShip to WorldShip Commodity Transfer
Slide deck by Dr. Greg Reese Miami University MATLAB An Introduction With Applications, 5 th Edition Dr. Amos Gilat The Ohio State University Chapter 4.
Introduction to Unix (CA263) File Processing. Guide to UNIX Using Linux, Third Edition 2 Objectives Explain UNIX and Linux file processing Use basic file.
Cell Arrays 1.Definition 2.Creating Cell Arrays 3.Referencing Cell Arrays 4.Augmenting Cell Arrays 5.Use of Cell Arrays 1.
MEGN 536 – Computational Biomechanics MATLAB: Getting Started Prof. Anthony J. Petrella Computational Biomechanics Group.
Introduction to File I/O High-Level Functions 1.Data files 2."High level" File I/O 3.dlmread() 4.xlsread() 1.
MATLAB Tutorial EE 327 Signals and Systems 1. What is MATLAB? MATLAB – Matrix Laboratory The premier number-crunching software Extremely useful for signal.
Basic File Input and Output Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See
Matlab Programming for Engineers Dr. Bashir NOURI Introduction to Matlab Matlab Basics Branching Statements Loops User Defined Functions Additional Data.
Functions CS 103 March 3, Review A function is a set of code we can execute on command to perform a specific task A function is a set of code we.
Functions CS 103. Review A function is a set of code we can execute on command to perform a specific task When we call a function, we can pass arguments.
CMPS 1371 Introduction to Computing for Engineers FILE Input / Output.
File I/O High-Level Functions 1. Definition 2. Is a High-Level function appropriate? 3. xlsread() 4. dlmread() 1.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting MySQL – Inserting Data.
Chapter 1 – Matlab Overview EGR1302. Desktop Command window Current Directory window Command History window Tabs to toggle between Current Directory &
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 5.3Math Library Functions Math library functions –perform.
Puff! The magic dragon, live by the tree… 第 3 章 檔案、函數、資料結構 files, functions, and data structures.
Files: By the end of this class you should be able to: Prepare for EXAM 1. create an ASCII file describe the nature of an ASCII text Use and describe string.
EGR 115 Introduction to Computing for Engineers MATLAB Basics 3: Array Operations Monday 08 Sept 2014 EGR 115 Introduction to Computing for Engineers.
Introduction to MATLAB Section2, statistics course Third year biomedical dept. Dina El Kholy, Ahmed Dalal.
Early File I/O To help you get started with your final project 1. Definition of “high level” 2. Is using a High Level function appropriate? 3. xlsread()
Non-standard ASCII to netCDF. CF Conventions REQUIRE Latitude Longitude Date/Time …for EVERY observation.
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 20P. 1Winter Quarter Propulsion Lab with.
1 CSE 2337 Chapter 7 Organizing Data. 2 Overview Import unstructured data Concatenation Parse Create Excel Lists.
Math 252: Math Modeling Eli Goldwyn Introduction to MATLAB.
SIMPLE FILTERS. CONTENTS Filters – definition To format text – pr Pick lines from the beginning – head Pick lines from the end – tail Extract characters.
Input Output IO and datafiles Credits also to Prof Selim Aksoy (Bilkent University.
Introduction to Matlab PHY September Why Matlab? No need to compile code Huge amount of built-in functions Highly optimized and fast, in general.
Manipulating MATLAB Matrices Chapter 4
Introduction to Matlab
MATLAB Introduction Dr. Theodore Cleveland University of Houston
Outline Matlab tutorial How to start and exit Matlab Matlab basics.
MATLAB DENC 2533 ECADD LAB 9.
Final Exam Review Part 4 - VBA
© 2016 Pearson Education, Inc.,Hoboken, NJ. All rights reserved.
Advanced Data Import & Export Jeff Henrikson
MATH 493 Introduction to MATLAB
CS100J 26 April. Matlab Use help button!!! Variables, values, types
MATLAB Tutorial Dr. David W. Graham.
8 6 MySQL Special Topics A Guide to MySQL.
Matlab Fundamentals: working with data.
Array Creation ENGR 1181 MATLAB 02.
funCTIONs and Data Import/Export
MCS/BCS.
Note on Indexing of Array Elements
Introduction to MATLAB
Islamic University of Gaza
Introduction to MATLAB
Chapter 20: Programming Functions
Using Script Files and Managing Data
Retrieving numerical values.
Programming with Matlab
Clip & Convert to ASCII Program Kelly Knapp Spring 2010
ME 123 Computer Applications I Lecture 5: Input and Output 3/17/03
Chapter 2 MATLAB Environment
Presentation transcript:

Functions (subprograms) Built-in functions (sin, cos, ln, etc.) User-defined functions Sin (3.14) (argument) Function name

User-defined functions Created as a .m file 1st line is function definition line function [output variables] = function_name(input variables) function_name same as filename Function is called from main script by [output variables] = function_name(input variables)

Local vs Global Variables Local variables Only recognized within function file Can reuse the same variable names in another function file Global variables Name (and values) recognized globally (in all files involved) Need to be declared as global in all files involved global a x q

Data files Data from lab instrumentation Saved in ASCII as pv_data.m (any extension except .mat) Data as numbers in columns and rows separated by space Using your favorite text editor Change any other delimiters (comma, colon) to space Remove any headers Load into Matlab by load pv_data.m Data is now available as variable(array) pv_data

Exporting data files Exporting an array A in Matlab session >>save my_results.txt A -ASCII To use other delimiters >>dlmwrite('my_results.txt',A,';' ) Default delimiter comma Space as delimiter by ' ' No delimiter by ''