funCTIONs and Data Import/Export

Slides:



Advertisements
Similar presentations
Introduction To MATLAB Programming
Advertisements

Introduction to MATLAB for Biomedical Engineering BME 1008 Introduction to Biomedical Engineering FIU, Spring 2015 Lesson 2: Element-wise vs. matrix operations.
Lecture 7 Debugging Code & Data Import/Export © 2007 Daniel Valentine. All rights reserved. Published by Elsevier.
Introduction to GTECH 201 Session 13. What is R? Statistics package A GNU project based on the S language Statistical environment Graphics package Programming.
A Brief Introduction to MATLAB Shibaji Shome and Rob MacLeod CVRTI University of Utah.
Lecture 7 Sept 17 Goals: Complete Chapter 4 Chapters 5 and 6.
Lecture 7 Sept 29 Goals: Chapters 5 and 6. Scripts Sequence of instructions that we may want to run can be stored in a file (known as script). by typing.
EGR 106 – Week 2 – Arrays & Scripts Brief review of last week Arrays: – Concept – Construction – Addressing Scripts and the editor Audio arrays Textbook.
2015/6/301 TransCAD Managing Data Tables. 2015/6/302 Create a New Table.
Fall 2006AE6382 Design Computing1 Matlab File & Directory Management Learning Objectives Define file input and output terminology Compare high and low.
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 File Management. MATLAB User File Management Matlab provides a group of commands to manage user files. For more information, type help iofun. pwd.
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.
ELG 3120 Signal and System Analysis 1 Introduction to MATLAB TAs Wei Zhang Ozgur Ekici (Section A)(Section B) ELG 3120 Lab Tutorial 1.
Computational Methods of Scientific Programming Lecturers Thomas A Herring, Room A, Chris Hill, Room ,
Basic File Input and Output Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See
Lecture 7 Sept 22 Goals: Chapters 5 and 6. Scripts Sequence of instructions that we may want to run can be stored in a file (known as script). by typing.
Getting Started with MATLAB 1. Fundamentals of MATLAB 2. Different Windows of MATLAB 1.
CMPS 1371 Introduction to Computing for Engineers FILE Input / Output.
Term 2, 2011 Week 1. CONTENTS Problem-solving methodology Programming and scripting languages – Programming languages Programming languages – Scripting.
MATLAB Environment ELEC 206 Computer Applications for Electrical Engineers Dr. Ron Hayne.
Language Basics and Data Types ● What and why of Matlab. ● Matlab desktop. ● Familiarize ourselves with basics of language. ● Basic types of data that.
COMP 116: Introduction to Scientific Programming Lecture 29: File I/O.
Lecture 20: Choosing the Right Tool for the Job. What is MATLAB? MATLAB is one of a number of commercially available, sophisticated mathematical computation.
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.
7. Data Import Export Lingma Acheson Department of Computer and Information Science IUPUI CSCI N207 Data Analysis Using Spreadsheets 1.
1 Lecture 4 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept.
Math 252: Math Modeling Eli Goldwyn Introduction to MATLAB.
Introduction to Programming on MATLAB Ecological Modeling Course Sep 11th, 2006.
User Defined Functions Spring EE 201. Class Learning Objectives  Achieve Comprehension LOL of User Defined Functions. Spring
Unit 2 Technology Systems
Working with files Saving and loading Matlab variables to and from .mat files does not require any special file handling, just use save() and load() However,
EEE 161 Applied Electromagnetics
Manipulating MATLAB Matrices Chapter 4
Introduction to Matlab
Appendix B MathScript Basics
Matlab Training Session 4: Control, Flow and Functions
MATLAB Basics Nafees Ahmed Asstt. Professor, EE Deptt DIT, DehraDun.
IMPORTING AND EXPORTING DATA
Other Kinds of Arrays Chapter 11
Other Kinds of Arrays Chapter 11
CQG XData Walkthrough.
Scripts & Functions Scripts and functions are contained in .m-files
Functions (subprograms)
(Mohammed Sami) Ashhab
User Defined Functions
Jeff Henrikson Lecture 11 Data Import & Export Jeff Henrikson 1.
Advanced Data Import & Export Jeff Henrikson
Python I/O.
Matlab review Matlab is a numerical analysis system
MATH 493 Introduction to MATLAB
Matlab Fundamentals: working with data.
Vectors and Matrices I.
Coding Concepts (Data Structures)
Code is on the Website Outline Comparison of Excel and R
CSCI N207 Data Analysis Using Spreadsheet
Communication and Coding Theory Lab(CS491)
Matlab Fundamentals: working with data.
INTRODUCTION TO MATLAB
Note on Indexing of Array Elements
Islamic University of Gaza
CSCI N317 Computation for Scientific Applications Unit 1 – 1 MATLAB
CSCI N207 Data Analysis Using Spreadsheet
Using Script Files and Managing Data
EECS Introduction to Computing for the Physical Sciences
Programming with Matlab
ME 123 Computer Applications I Lecture 5: Input and Output 3/17/03
Chapter 2 MATLAB Environment
Presentation transcript:

funCTIONs and Data Import/Export CSCI N317 Computation for Scientific Applications Unit 1 - 3 MATLAB funCTIONs and Data Import/Export

Outline Common built-in functions available to use User defined functions Data import/export

Common Built-in Functions Function revisit

Common Built-in Functions Find a list of MATLAB commands and functions Type helpwin at the command line Click on the Help button https://www.mathworks.com/help/matlab/functionlist.html

User Defined Functions You can create your own functions, e.g. y = f(x) A function has three components Function name and definition – f Function input – x Function output – y Function definition can be stored in a script file, called Function M-file. Function file must start with the key word “function”. Function name and the file name must be the same.

User Defined Functions

Return Values A function doesn’t have to return values

Return Values A function can return more than one values Return values are specified in square brackets separated by comma or space

Return Values Function output can be vectors.

Local Variables vs Global Variables variables defined inside the function definition available in the function only, thus cannot be accessed in the workspace (outside of the function).

Local Variables vs Global Variables variables defined outside the function definition Available both in function and workspace.

Importing and Exporting Data Use the load function - Data imported from the text file will be stored in a variable with the same name as the file; Can use the function form of the command to save to a different variable.

Importing and Exporting Data Read Excel spreadsheet files http://www.mathworks.com/help/matlab/ref/xlsread.html

Importing and Exporting Data Read Excel spreadsheet files

Importing and Exporting Data Use the GUI “Import Data” feature. Data can be imported as Column Vectors: Each column becomes a vector variable, data is not stored as a single variable. Matrix: Text data becomes NaN Cell Array: array that can contain values with mixed data types, can access data using array index. http://www.mathworks.com/help/matlab/cell-arrays.html Table: Arrays in tabular form whose named columns can have different types, can access data using array index or row/column name. http://www.mathworks.com/help/matlab/ref/table.html

Importing and Exporting Data You can save data in a MATLAB session into a file on hard disk. Text format in ASCII codes, to be opened by text editors

Importing and Exporting Data Write a data into a Excel spreadsheet file http://www.mathworks.com/help/matlab/import_export/exporting-to-excel-spreadsheets.html

Importing and Exporting Data Binary format, the file has an extension .mat, to be opened by MATLAB