CS100J 26 April. Matlab Use help button!!! Variables, values, types

Slides:



Advertisements
Similar presentations
Introduction to Programming using Matlab Session 2 P DuffourJan 2008.
Advertisements

1 PHP Statement Constructs Server Scripting. 5-2 Basic Statement All Statements end in a semicolon. Statements are delimited from the HTML code by enclosing.
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 19P. 1Winter Quarter MATLAB: Script and.
Scripts and Flow Control. Scripts So far we have been entering commands directly into the command line But there is a better way Script files (and functions)
Executes a statement or statements for a number of times – iteration. Syntax for(initialize; test; increment) { // statements to be executed } Initial.
Lecture 5 Review Programming Program Structures Comparison Repetition: looping or iteration Conditional execution: branching Bubble Sort.
Al-Amer An Introduction to MATLAB Dr. Samir Al-Amer Term 062.
Programming For Nuclear Engineers Lecture 12 MATLAB (3) 1.
EPSII 59:006 Spring Topics Using TextPad If Statements Relational Operators Nested If Statements Else and Elseif Clauses Logical Functions For Loops.
INTRO TO PROGRAMMING Chapter 2. M-files While commands can be entered directly to the command window, MATLAB also allows you to put commands in text files.
1 16 November Matlab Copied from the original document on file at the Smokey Valley Genealogical Society and Library in Salina, KS, and reprinted by The.
MEGN 536 – Computational Biomechanics MATLAB: Getting Started Prof. Anthony J. Petrella Computational Biomechanics Group.
COMP 116: Introduction to Scientific Programming Lecture 28: Midterm #2 Review.
Vectors and Matrices In MATLAB a vector can be defined as row vector or as a column vector. A vector of length n can be visualized as matrix of size 1xn.
Getting Started with MATLAB 1. Fundamentals of MATLAB 2. Different Windows of MATLAB 1.
MATLAB Practice 1 Introducing MATLAB Lecture Notes on Video Search & Mining, Spring 2012 Presented by Jun Hee Yoo Biointelligence Laboratory School of.
What does C store? >>A = [1 2 3] >>B = [1 1] >>[C,D]=meshgrid(A,B) c) a) d) b)
CONTENTS Processing structures and commands Control structures – Sequence Sequence – Selection Selection – Iteration Iteration Naming conventions – File.
Chapter 1 – Matlab Overview EGR1302. Desktop Command window Current Directory window Command History window Tabs to toggle between Current Directory &
Introduction to Matlab Module #4 Page 1 Introduction to Matlab Module #4 – Programming Topics 1.Programming Basics (fprintf, standard input) 2.Relational.
Other Variable Types Dim lab as String makes a box that can store a label tag Dim ColHead As String ColHead = “function” ColHead function Dim lab as Boolean.
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.
A simple classification problem Extract attributes Pattern Pattern recognition decision x C1 C2.
Digital Image Processing Introduction to M-function Programming.
Matlab Programming a logical approach. Outline Announcements: –Homework I: due Wed. by 5, by –Last day to add/drop or change credit/audit Iteration.
INTRODUCTION TO MATLAB Dr. Hugh Blanton ENTC 4347.
Digital Image Processing Introduction to MATLAB. Background on MATLAB (Definition) MATLAB is a high-performance language for technical computing. The.
General Computer Science for Engineers CISC 106 Lecture 12 James Atlas Computer and Information Sciences 08/03/2009.
Click left mouse button to proceed. Windows Tutorial Searching For Files CST-133 Lab AW © Delta College CST Faculty.
Interduction to MATLAB (part 2) Manal Alotaibi Mathematics department College of science King saud university.
Extending MATLAB Write your own scripts and/or functions Scripts and functions are plain text files with extension.m (m-files) To execute commands contained.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
Matlab Programming a logical approach. Outline Announcements: –Homework I: due Wed. by 5, by –Remember: text & subject –Last day to add/drop or.
1 CS100J April Course evaluation. Please complete the online course evaluation form for CS100J. It does indeed help us improve the course. Completion.
Introduction to Programming Python Lab 6: Relational Operators and Boolean Variables 12 February PythonLab6 lecture slides.ppt Ping Brennan
Introduction to Programming G50PRO University of Nottingham Unit 6 : Control Flow Statements 2 Paul Tennent
Basics of MATLAB 2- Programming in MATLAB By DR. Wafaa Shabana
MATLAB The name of MATLAB stands for matrix laboratory. Starting a MATLAB Session -On Microsoft® Windows® platforms, start the MATLAB program by double-clicking.
Windows Tutorial 2 Organizing Your Files
Introduction to Programming
EEE 161 Applied Electromagnetics
Release Numbers MATLAB is updated regularly
Prof. Mark Glauser Created by: David Marr
Matlab Training Session 4: Control, Flow and Functions
Project 9 Creating Pop-up Windows, Adding Scrolling Messages, and Validating Forms.
Introduction to Programming
Introduction to Programming
Scripts & Functions Scripts and functions are contained in .m-files
MATLAB DENC 2533 ECADD LAB 9.
Introduction to Programming
Matlab review Matlab is a numerical analysis system
MATLAB (Lecture 2) BY:MAHA ALMOUSA.
MATLAB – Basic For Loops
Use of Mathematics using Technology (Maltlab)
The Web Wizard’s Guide To JavaScript
Introduction to Programming
Digital Image Processing
Introduction to Programming Using Python PART 2
funCTIONs and Data Import/Export
Conditional Statements
CSCI N317 Computation for Scientific Applications Unit 1 – 1 MATLAB
Vectors and Matrices In MATLAB a vector can be defined as row vector or as a column vector. A vector of length n can be visualized as matrix of size 1xn.
CSCI N207 Data Analysis Using Spreadsheet
Using Script Files and Managing Data
Scripts In Matlab.
ENEE222 Elements of Discrete Signal Analysis Lab 3 1.
Introduction to Programming
Introduction to Programming
JavaScript 101 Lesson 8: Loops.
MATLAB (Lecture 2) BY:MAHA ALMOUSA.
Presentation transcript:

CS100J 26 April. Matlab Use help button!!! Variables, values, types Type commands here Double click on an entry to move it to command window. Use arrow keys

Scripts Obtained by clicking help and searching for “script”

Scripts Script file: is an external file that contains a sequence of MATLAB statements. Has extension .m, called M-file. Type the filename to execute statements. Useful for automating blocks of MATLAB commands, such as computations you have to perform repeatedly from the command line. Scripts can operate on data in the workspace or can create new data on which to operate. Any variables they create remain in the workspace No declarations or begin/end delimiters required. Comments: Any text following a percent sign (%) on a given line is comment text. Comments can appear on lines by themselves or can appear after a statement on an executable line.

Created using File->New-> M-File Created using File->New-> M-File. Stored automatically in folder work within MatLab. You can navigate to store it where you want. I If you work in a Cornell lab, save your m-files on your own storage key or email them to yourself. Example of a script

Conditional statements Logical operators. 0 represents false Not-0 represents true A & B A | B ~A Short circuit evaluation: A && B A || B if expression statements end if expression1 statements1 elseif expression2 statements2 else statements3 Found these by typing “logical operators” into search window of Help Found these by typing “if” into search window of Help

Loops %Example: binary search t= (size(r)); nocols= t(2); x= -5; % Row Vector r is sorted. % Store in h an integer that satisfies % r[1..h] <= x < f[h+1..nocols] h= 0; k= nocols+1; %invariant: r[1..h] <= x < f[k..nocols] while (h+1 < k) e= floor((h+k)/2); if (r(e) <= x ) h= e; else k= e; end for index= start: increment: end statements End If you leave out the increment, 1 is used. while expression statements end Found this info by typing “loop” into search window of Help