Using Script Files and Managing Data

Slides:



Advertisements
Similar presentations
User-defined Functions Selim Aksoy Bilkent University Department of Computer Engineering
Advertisements

Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 19P. 1Winter Quarter MATLAB: Script and.
EGR 106 – Week 2 – Arrays Definition, size, and terminology Construction methods Addressing and sub-arrays Some useful functions for arrays Character arrays.
EGR 106 – Week 2 – Arrays & Scripts Brief review of last week Arrays: – Concept – Construction – Addressing Scripts and the editor Audio arrays Textbook.
Introduction to MATLAB MECH 300H Spring Starting of MATLAB.
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.
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.
BRIAN D. HAHN AND DANIEL T. VALENTINE THIRD EDITION Essential MATLAB® for Engineers and Scientists.
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.
ECE 1304 Introduction to Electrical and Computer Engineering Section 1.1 Introduction to MATLAB.
Introduction to Engineering MATLAB – 6 Script Files - 1 Agenda Script files.
Introduction to Engineering MATLAB – 2 Introduction to MATLAB - 2 Agenda Defining Variables MATLAB Windows.
CMPS 1371 Introduction to Computing for Engineers MatLab.
What does C store? >>A = [1 2 3] >>B = [1 1] >>[C,D]=meshgrid(A,B) c) a) d) b)
Chapter 3 MATLAB Fundamentals Introduction to MATLAB Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Chapter 1 – Matlab Overview EGR1302. Desktop Command window Current Directory window Command History window Tabs to toggle between Current Directory &
ENG College of Engineering Engineering Education Innovation Center 1 Array Accessing and Strings in MATLAB Topics Covered: 1.Array addressing. 2.
Getting Started with MATLAB (part2) 1. Basic Data manipulation 2. Basic Data Understanding 1. The Binary System 2. The ASCII Table 3. Creating Good Variables.
Chapter 6 Review: User Defined Functions Introduction to MATLAB 7 Engineering 161.
ENG College of Engineering Engineering Education Innovation Center 1 More Script Files in MATLAB Script File I/O : Chapter 4 1.Global Variables.
Introduction to Engineering MATLAB – 7 Script Files - 2 Agenda Script files continued.
EGR 115 Introduction to Computing for Engineers Introduction to MATLAB Friday 29 August 2014 EGR 115 Introduction to Computing for Engineers.
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 Engineering MATLAB – 4 Arrays Agenda Creating arrays of numbers  Vectors: 1-D Arrays  Arrays: 2-D Arrays Array Addressing Strings & String.
BRIAN D. HAHN AND DANIEL T. VALENTINE THIRD EDITION Essential MATLAB® for Engineers and Scientists.
ISLAMIC UNIVERSITY OF GAZA FACULTY OF ENGINEERING ISLAMIC UNIVERSITY OF GAZA FACULTY OF ENGINEERING Computer Programming Lab 1 Programming Basics By Eng.
Math 252: Math Modeling Eli Goldwyn Introduction to MATLAB.
Introduction to Programming on MATLAB Ecological Modeling Course Sep 11th, 2006.
MATLAB (Matrix Algebra laboratory), distributed by The MathWorks, is a technical computing environment for high performance numeric computation and.
User Defined Functions Spring EE 201. Class Learning Objectives  Achieve Comprehension LOL of User Defined Functions. Spring
MATLAB The name of MATLAB stands for matrix laboratory. Starting a MATLAB Session -On Microsoft® Windows® platforms, start the MATLAB program by double-clicking.
1.3 ARITHMETIC OPERATIONS WITH SCALARS
ECE 1304 Introduction to Electrical and Computer Engineering
Release Numbers MATLAB is updated regularly
BAHASA PEMROGRAMAN MATLAB as an Engineering Tool & Programming Language a lecture note for Civil Engineering students of PETRA Christian University Doddy.
Introduction to Matlab
Appendix B MathScript Basics
Matlab Training Session 4: Control, Flow and Functions
Lecture: MATLAB Chapter 1 Introduction
Introduction to MATLAB for Engineers, Third Edition
Basic operations in Matlab
Two-Dimensional Plots
Scripts & Functions Scripts and functions are contained in .m-files
A computer program is a sequence of computer commands.
User Defined Functions
Lecture 1: Introduction
MATLAB (Lecture 2) BY:MAHA ALMOUSA.
MATH 493 Introduction to MATLAB
Use of Mathematics using Technology (Maltlab)
Plotting Multiple Graphs In The Same Plot
Chapter2 Creating Arrays
Communication and Coding Theory Lab(CS491)
Introduction to Matlab
funCTIONs and Data Import/Export
Conditional Statements
ARRAY DIVISION Identity matrix Islamic University of Gaza
Islamic University of Gaza
CSCI N317 Computation for Scientific Applications Unit 1 – 1 MATLAB
Islamic University of Gaza
Using SQL*Plus.
Experiment No. (1) - an introduction to MATLAB
Histograms are plots that show the distribution of data.
USING ARRAYS IN MATLAB BUILT-IN MATH FUNCTIONS
MATLAB (Lecture 2) BY:MAHA ALMOUSA.
Computer Simulation Lab
Introduction to Matlab
ME 123 Computer Applications I Lecture 5: Input and Output 3/17/03
Chapter 2 MATLAB Environment
Electrical and Computer Engineering Department SUNY – New Paltz
Presentation transcript:

Using Script Files and Managing Data Islamic University of Gaza Faculty of Engineering Civil Engineering Department CH4 Using Script Files and Managing Data A script file is a list of MATLAB commands, called a program, that is saved in a file. Computer Programming Lecture 10

4.1 The Matlab Workspace And The Workspace Window Islamic University of Gaza Faculty of Engineering Civil Engineering Department 4.1 The Matlab Workspace And The Workspace Window The MATLAB workspace consists of the set of variables (named arrays) that are defined and stored during a MATLAB session. It includes variables that have been defined in the Command Window and variables defined when script files are executed. This means that the Command Window and script files share the same memory zone within the computer. Computer Programming Lecture 10

Islamic University of Gaza Faculty of Engineering Civil Engineering Department Computer Programming Lecture 10

Islamic University of Gaza Faculty of Engineering Civil Engineering Department Computer Programming Lecture 10

Islamic University of Gaza Faculty of Engineering Civil Engineering Department Computer Programming Lecture 10

Islamic University of Gaza Faculty of Engineering Civil Engineering Department Computer Programming Lecture 10

Islamic University of Gaza Faculty of Engineering Civil Engineering Department 4.2 INPUT TO A SCRIPT FILE When a script file is executed, the variables that are used in the calculations within the file must have assigned values. In other words, the variables must be in the workspace. The assignment of a value to a variable can be done in three ways, depending on where and how the variable is defined. Computer Programming Lecture 10

1. The variable is defined and assigned a value in the script file. Islamic University of Gaza Faculty of Engineering Civil Engineering Department 1. The variable is defined and assigned a value in the script file. In this case the assignment of a value to the variable is part of the script file. If the user wants to RUN the file with a different variable value, the file must be edited and the assignment of the variable changed. Then, after the file is saved, it can be executed again. Computer Programming Lecture 10

Islamic University of Gaza Faculty of Engineering Civil Engineering Department Computer Programming Lecture 10

2. The variable is defined and assigned a value in the Command Window. Islamic University of Gaza Faculty of Engineering Civil Engineering Department 2. The variable is defined and assigned a value in the Command Window. In this case the assignment of a value to the variable is done in the Command Window. (Recall that the variable is recognized in the script file.) If the user wants to run the script file with a different value for the variable, the new value is assigned in the Command Window and the file is executed again. Computer Programming Lecture 10

Islamic University of Gaza Faculty of Engineering Civil Engineering Department Computer Programming Lecture 10

Islamic University of Gaza Faculty of Engineering Civil Engineering Department Computer Programming Lecture 10

This is done by using the input command for creating the variable. Islamic University of Gaza Faculty of Engineering Civil Engineering Department 3. The variable is defined in the script file, but a specific value is entered in the Command Window when the script file is executed. In this case the variable is defined in the script file, and when the file is executed, the user is prompted to assign a value to the variable in the Command Window. This is done by using the input command for creating the variable. Computer Programming Lecture 10

Islamic University of Gaza Faculty of Engineering Civil Engineering Department When the input command is executed as the script file runs, the string is displayed in the Command Window. The string is a message prompting the user to enter a value that is assigned to the variable. The user types the value and presses the Enter key. This assigns the value to the variable. As with any variable, the variable and its assigned value will be displayed in the Command Window unless a semicolon is typed at the very end of the input command Computer Programming Lecture 10

Islamic University of Gaza Faculty of Engineering Civil Engineering Department Computer Programming Lecture 10

Islamic University of Gaza Faculty of Engineering Civil Engineering Department In this example scalars are assigned to the variables. In general, however, vectors and arrays can also be assigned. This is done by typing the array in the same way that it is usually assigned to a variable (left bracket, then typing row by row, and a right bracket). Computer Programming Lecture 10

Islamic University of Gaza Faculty of Engineering Civil Engineering Department Computer Programming Lecture 10