Programming in MATLAB
|
|
- Gertrude Ball
- 5 years ago
- Views:
Transcription
1 2. Scripts, Input/Output and if Faculty of mathematics, physics and informatics Comenius University in Bratislava October 7th, 2015
2 Scripts
3 Scripts script is basically just a sequence of commands the same kind we enter into the command window scripts are stored as a plain text files with an.m extension so called m-files can also contain functions more on that later name of the script can be used as a command only works in the current directory, to change: GUI method: a drop-down edit box, top left console method: cd [path] to change cd to display S = cd to store
4 Script example let s have a script file called randmul.m: % Test matrix multipication. % generate random inputs A = rand(5); x = rand(1,5); % test res = x * A we can run it by typing it s name: >> randmul res =
5 Comments the lines starting with % are comments they are ignored (not executed) they serve as documentation the first block of uninterrupted comments is special: >> help randmul Test matrix multiplication. help command is text-only (and quick) use doc for complete HTML documentation can sometimes crash or freeze save often maybe prefer searching the web
6 Input
7 input() function asking for user input: >> a = input('enter a number: ') Enter a number: 4.7 a = the 4.7 was entered by keyboard the rest is MATLAB output
8 input() function the input is actually an expression: >> b = input('enter an expression: ') Enter an expression: 2*sin(pi/3) b = even variables can be used: >> c = input('enter an expression: ') Enter an expression: 2 * b c =
9 input() function so we can input vectors and matrices: >> A = input('enter a matrix: ') Enter a matrix: [ 1 2 3; 4 5 6; ] A =
10 input() function and strings: >> s = input('your name: ') Your name: 'Thomas' s = Thomas but more conveniently: >> t = input('favorite color: ', 's') Favorite color: blue t = blue
11 Output
12 Output mentioning a variable prints it: >> e = exp(1); >> e e = this is equivalent to display(e) alternatives: disp fprintf
13 disp() function display the value of an expression/variable: >> disp(e) >> disp('text') text >> disp([1 2 3; 4 5 6]) basically just omits the name of the variable / ans =
14 fprintf() function file print formatted function from the C s standard library formatted output optionally to a file (more on that later) precise control of formatting not-so-easy to use
15 fprintf() function syntax: fprintf(format string, arguments) example: >> fprintf('e is %f\n', e) e is the %f is a placeholder there should be one for each argument the \n is an escape sequence this particular one outputs a newline
16 Format strings (most) placeholders: %o integers (octal) %d integers (decimal) %x, %X integers (hexadecimal) %c character %s string %f real number (fixed-point) %e, %E real number (scientific) %g, %G real number (compact)
17 Format strings padding output to n digits with spaces or zeros: >> fprintf('[%d]\n', 4); [4] >> fprintf('[%3d]\n', 4); [ 4] >> fprintf('[%03d]\n', 4); [004] forcing the printing of a sign (minus is always printed) >> fprintf('[%+03d]\n', 4); [+04]
18 Format strings controlling the precision: >> disp(e) >> fprintf('%f\n', e) >> fprintf('%.2f\n', e) 2.72 >> fprintf('%+07.2f\n', e)
19 Escape sequences some characters have special meaning to print them, we must use an escape sequence: \n newline \t tabulator \\ backslash '' single quote %% percent sign
20 Printing vectors and matrices printing a vector: >> fprintf('%d\n', [1, 2, 3]) the print command executes for each element in matrices, this means in column-order it s easier to just use disp()
21 Logic
22 The logical type there are only two logical values: false, 0 true, 1 we can convert any number to a logical value: >> logical([ pi Inf ]) ans = zero is false and everything else is true
23 Relational operators we can also get logical values from comparisons: == equality ~= inequality <, > strict comparison <=, >= weak comparison for example: >> 1 == 2 ans = 0 >> 3 >= 2 ans = 1
24 Logic operators we can manipulate them using logic operators: ~, not negation, or disjunction, alternative &&, and conjuction xor exclusive or for example: >> [ ~0 not(1) ] ans = 1 0 >> or(1, 0) ans = 1 >> 1&&0 ans = 0 >> xor(1,0) ans = 1
25 Conditionals
26 if statement if syntax: if condition command command... command end example: >> temp = 120; >> if temp>100; disp('boiling!'); end >> if temp<0; disp('freezing!'); end Boiling!
27 Example: sgn script sgn.m x = input('enter a number: '); if x > 0 disp('positive') end if x == 0 disp('zero') end if x < 0 disp('negative') end
28 if-else statement if-else syntax: if condition command(s) else command(s) end example: >> temp = 83; >> if temp>100; disp('boiling!');... else disp('not boiling.'); end Not boiling.
29 Example: sgn script #2 nested ifs: sgn.m x = input('enter a number: '); if x > 0 disp('positive') else if x == 0 disp('zero') else disp('negative') end end
30 if-elseif statement if-elseif syntax: if condition command(s) elseif condition commmand(s) elseif condition command(s)... else command(s) end any number of elseif clauses the else clause is optional
31 Example: sgn script #3 using elseif: sgn.m x = input('enter a number: '); if x > 0 disp('positive') elseif x == 0 disp('zero') else disp('negative') end
7 Control Structures, Logical Statements
7 Control Structures, Logical Statements 7.1 Logical Statements 1. Logical (true or false) statements comparing scalars or matrices can be evaluated in MATLAB. Two matrices of the same size may be compared,
More informationMechanical Engineering Department Second Year
Lecture 3: Control Statements if Statement It evaluates a logical expression and executes a group of statements when the expression is true. The optional (elseif) and else keywords provide for the execution
More informationChapter 3: Programming with MATLAB
Chapter 3: Programming with MATLAB Choi Hae Jin Chapter Objectives q Learning how to create well-documented M-files in the edit window and invoke them from the command window. q Understanding how script
More informationMATLAB Laboratory 10/07/10 Lecture. Chapter 7: Flow Control in Programs
MATLAB Laboratory 10/07/10 Lecture Chapter 7: Flow Control in Programs Lisa A. Oberbroeckling Loyola University Maryland loberbroeckling@loyola.edu L. Oberbroeckling (Loyola University) MATLAB 10/07/10
More informationCompact Matlab Course
Compact Matlab Course MLC.1 15.04.2014 Matlab Command Window Workspace Command History Directories MLC.2 15.04.2014 Matlab Editor Cursor in Statement F1 Key goes to Help Information MLC.3 15.04.2014 Elementary
More informationProgramming 1. Script files. help cd Example:
Programming Until now we worked with Matlab interactively, executing simple statements line by line, often reentering the same sequences of commands. Alternatively, we can store the Matlab input commands
More informationAn Introduction to MATLAB
An Introduction to MATLAB Day 1 Simon Mitchell Simon.Mitchell@ucla.edu High level language Programing language and development environment Built-in development tools Numerical manipulation Plotting of
More informationECE 102 Engineering Computation
ECE 102 Engineering Computation Phillip Wong MATLAB Loops for while break / continue Loops A loop changes the execution flow in a program. What happens in a loop? For each iteration of the loop, statements
More informationIntroduction to MATLAB
Introduction to MATLAB The Desktop When you start MATLAB, the desktop appears, containing tools (graphical user interfaces) for managing files, variables, and applications associated with MATLAB. The following
More informationControl Structures. March 1, Dr. Mihail. (Dr. Mihail) Control March 1, / 28
Control Structures Dr. Mihail March 1, 2015 (Dr. Mihail) Control March 1, 2015 1 / 28 Overview So far in this course, MATLAB programs consisted of a ordered sequence of mathematical operations, functions,
More informationCME 192: Introduction to Matlab
CME 192: Introduction to Matlab Matlab Basics Brett Naul January 15, 2015 Recap Using the command window interactively Variables: Assignment, Identifier rules, Workspace, command who and whos Setting the
More informationSelection Statements. Chapter 4. Copyright 2013 Elsevier Inc. All rights reserved 1
Selection Statements Chapter 4 Copyright 2013 Elsevier Inc. All rights reserved 1 Recall Relational Expressions The relational operators in MATLAB are: > greater than < less than >= greater than or equals
More informationRelational and Logical Operators. MATLAB Laboratory 10/07/10 Lecture. Chapter 7: Flow Control in Programs. Examples. Logical Operators.
Relational and Logical Operators MATLAB Laboratory 10/07/10 Lecture Chapter 7: Flow Control in Programs Both operators take on form expression1 OPERATOR expression2 and evaluate to either TRUE (1) or FALSE
More informationWhy use MATLAB? Mathematcal computations. Used a lot for problem solving. Statistical Analysis (e.g., mean, min) Visualisation (1D-3D)
MATLAB(motivation) Why use MATLAB? Mathematcal computations Used a lot for problem solving Statistical Analysis (e.g., mean, min) Visualisation (1D-3D) Signal processing (Fourier transform, etc.) Image
More informationLecture 1: Hello, MATLAB!
Lecture 1: Hello, MATLAB! Math 98, Spring 2018 Math 98, Spring 2018 Lecture 1: Hello, MATLAB! 1 / 21 Syllabus Instructor: Eric Hallman Class Website: https://math.berkeley.edu/~ehallman/98-fa18/ Login:!cmfmath98
More informationCSE 123. Lecture 9. Formatted. Input/Output Operations
CSE 123 Lecture 9 Formatted Input/Output Operations fpintf function writes formatted data in a user specified format to a file fid fprintf Function Format effects only the display of variables not their
More informationIntroduction to Matlab. Summer School CEA-EDF-INRIA 2011 of Numerical Analysis
Introduction to Matlab 1 Outline What is Matlab? Matlab desktop & interface Scalar variables Vectors and matrices Exercise 1 Booleans Control structures File organization User defined functions Exercise
More informationInteractive MATLAB use. Often, many steps are needed. Automated data processing is common in Earth science! only good if problem is simple
Chapter 2 Interactive MATLAB use only good if problem is simple Often, many steps are needed We also want to be able to automate repeated tasks Automated data processing is common in Earth science! Automated
More informationC/C++ Programming for Engineers: Matlab Branches and Loops
C/C++ Programming for Engineers: Matlab Branches and Loops John T. Bell Department of Computer Science University of Illinois, Chicago Review What is the difference between a script and a function in Matlab?
More informationBranches, Conditional Statements
Branches, Conditional Statements Branches, Conditional Statements A conditional statement lets you execute lines of code if some condition is met. There are 3 general forms in MATLAB: if if/else if/elseif/else
More informationCS 221 Lecture. Tuesday, 11 October 2011
CS 221 Lecture Tuesday, 11 October 2011 "Computers in the future may weigh no more than 1.5 tons." - Popular Mechanics, forecasting the relentless march of science, 1949. Today s Topics 1. Announcements
More informationES 117. Formatted Input/Output Operations
ES 117 Formatted Input/Output Operations fpintf function writes formatted data in a user specified format to a file fid fprintf Function Format effects only the display of variables not their values through
More informationIntroduction to. The Help System. Variable and Memory Management. Matrices Generation. Interactive Calculations. Vectors and Matrices
Introduction to Interactive Calculations Matlab is interactive, no need to declare variables >> 2+3*4/2 >> V = 50 >> V + 2 >> V Ans = 52 >> a=5e-3; b=1; a+b Most elementary functions and constants are
More informationFiles and File Management Scripts Logical Operations Conditional Statements
Files and File Management Scripts Logical Operations Conditional Statements Files and File Management Matlab provides a group of commands to manage user files pwd: Print working directory displays the
More informationMatlab Programming Arrays and Scripts 1 2
Matlab Programming Arrays and Scripts 1 2 Mili I. Shah September 10, 2009 1 Matlab, An Introduction with Applications, 2 nd ed. by Amos Gilat 2 Matlab Guide, 2 nd ed. by D. J. Higham and N. J. Higham Matrix
More informationConstraint-based Metabolic Reconstructions & Analysis H. Scott Hinton. Matlab Tutorial. Lesson: Matlab Tutorial
1 Matlab Tutorial 2 Lecture Learning Objectives Each student should be able to: Describe the Matlab desktop Explain the basic use of Matlab variables Explain the basic use of Matlab scripts Explain the
More informationSuch JavaScript Very Wow
Such JavaScript Very Wow Lecture 9 CGS 3066 Fall 2016 October 20, 2016 JavaScript Numbers JavaScript numbers can be written with, or without decimals. Extra large or extra small numbers can be written
More informationWhat is MATLAB and howtostart it up?
MAT rix LABoratory What is MATLAB and howtostart it up? Object-oriented high-level interactive software package for scientific and engineering numerical computations Enables easy manipulation of matrix
More information12 whereas if I terminate the expression with a semicolon, the printed output is suppressed.
Example 4 Printing and Plotting Matlab provides numerous print and plot options. This example illustrates the basics and provides enough detail that you can use it for typical classroom work and assignments.
More informationIntroduction to MATLAB Programming. Chapter 3. Linguaggio Programmazione Matlab-Simulink (2017/2018)
Introduction to MATLAB Programming Chapter 3 Linguaggio Programmazione Matlab-Simulink (2017/2018) Algorithms An algorithm is the sequence of steps needed to solve a problem Top-down design approach to
More informationMATLAB BASICS. M Files. Objectives
Objectives MATLAB BASICS 1. What is MATLAB and why has it been selected to be the tool of choice for DIP? 2. What programming environment does MATLAB offer? 3. What are M-files? 4. What is the difference
More informationCOMP MATLAB.
COMP110031 MATLAB chenyang@fudan.edu.cn M 2 M 3 M 4 M 5 M 6 M script MATLAB MATLAB 7 M function M function [y1,...,yn] = myfunc(x1,...,xm) myfunc x1,...,xm y1,...,yn eters 8 function y=myfunc(x) y=x+1;
More informationSMS 3515: Scientific Computing. Sem /2015
s s SMS 3515: Scientific Computing Department of Computational and Theoretical Sciences, Kulliyyah of Science, International Islamic University Malaysia. Sem 1 2014/2015 The if s that are conceptually
More information12/22/11. Java How to Program, 9/e. Help you get started with Eclipse and NetBeans integrated development environments.
Java How to Program, 9/e Education, Inc. All Rights Reserved. } Java application programming } Use tools from the JDK to compile and run programs. } Videos at www.deitel.com/books/jhtp9/ Help you get started
More informationUnit 4. Input/Output Functions
Unit 4 Input/Output Functions Introduction to Input/Output Input refers to accepting data while output refers to presenting data. Normally the data is accepted from keyboard and is outputted onto the screen.
More informationCEMTool Tutorial. Control statements
CEMTool Tutorial Control statements Overview This tutorial is part of the CEMWARE series. Each tutorial in this series will teach you a specific topic of common applications by explaining theoretical concepts
More informationMATLAB Introduction to MATLAB Programming
MATLAB Introduction to MATLAB Programming MATLAB Scripts So far we have typed all the commands in the Command Window which were executed when we hit Enter. Although every MATLAB command can be executed
More informationCH6: Programming in MATLAB
CH6: Programming in MATLAB 1- Relational and Logical operators: Relational operators: Examples Result >> 5>8 0 >> a= 6~=2 a=1 >> b= (3>2)+(5*2==10*1)*(32>=128/4) b=2 >> c= 8/(29) c=?? Order of
More informationStokes Modelling Workshop
Stokes Modelling Workshop 14/06/2016 Introduction to Matlab www.maths.nuigalway.ie/modellingworkshop16/files 14/06/2016 Stokes Modelling Workshop Introduction to Matlab 1 / 16 Matlab As part of this crash
More informationStep by step set of instructions to accomplish a task or solve a problem
Step by step set of instructions to accomplish a task or solve a problem Algorithm to sum a list of numbers: Start a Sum at 0 For each number in the list: Add the current sum to the next number Make the
More informationPace University. Fundamental Concepts of CS121 1
Pace University Fundamental Concepts of CS121 1 Dr. Lixin Tao http://csis.pace.edu/~lixin Computer Science Department Pace University October 12, 2005 This document complements my tutorial Introduction
More informationCS227-Scientific Computing. Lecture 3-MATLAB Programming
CS227-Scientific Computing Lecture 3-MATLAB Programming Contents of this lecture Relational operators The MATLAB while Function M-files vs script M-files The MATLAB for Logical Operators The MATLAB if
More informationAttia, John Okyere. Control Statements. Electronics and Circuit Analysis using MATLAB. Ed. John Okyere Attia Boca Raton: CRC Press LLC, 1999
Attia, John Okyere. Control Statements. Electronics and Circuit Analysis using MATLAB. Ed. John Okyere Attia Boca Raton: CRC Press LLC, 1999 1999 by CRC PRESS LLC CHAPTER THREE CONTROL STATEMENTS 3.1 FOR
More informationMcTutorial: A MATLAB Tutorial
McGill University School of Computer Science Sable Research Group McTutorial: A MATLAB Tutorial Lei Lopez Last updated: August 2014 w w w. s a b l e. m c g i l l. c a Contents 1 MATLAB BASICS 3 1.1 MATLAB
More informationECE Lesson Plan - Class #3 Script M-files, Program Control, and Complex Numbers
ECE 201 - Lesson Plan - Class #3 Script M-files, Program Control, and Complex Numbers Script M-files : A script file is an external file that contains a sequence of MATLAB. By typing the filename, subsequent
More informationAn Introduction to MATLAB. Lab tutor : Dennis Yang LIU Lab 1: Sept. 11, 2014
Lab 1 of COMP 319 An Introduction to MATLAB Lab tutor : Dennis Yang LIU Email: csygliu@comp.polyu.edu.hk Lab 1: Sept. 11, 2014 1 Outline of Lab 1 Introduction to the Lab Matlab overview Basic manipulation
More informationProgramming for Experimental Research. Flow Control
Programming for Experimental Research Flow Control FLOW CONTROL In a simple program, the commands are executed one after the other in the order they are typed. Many situations require more sophisticated
More informationChapter 2, Part I Introduction to C Programming
Chapter 2, Part I Introduction to C Programming C How to Program, 8/e, GE 2016 Pearson Education, Ltd. All rights reserved. 1 2016 Pearson Education, Ltd. All rights reserved. 2 2016 Pearson Education,
More informationGetting started with C++ (Part 2)
Getting started with C++ (Part 2) CS427: Elements of Software Engineering Lecture 2.2 11am, 16 Jan 2012 CS427 Getting started with C++ (Part 2) 1/22 Outline 1 Recall from last week... 2 Recall: Output
More informationCreates a 1 X 1 matrix (scalar) with a value of 1 in the column 1, row 1 position and prints the matrix aaa in the command window.
EE 350L: Signals and Transforms Lab Spring 2007 Lab #1 - Introduction to MATLAB Lab Handout Matlab Software: Matlab will be the analytical tool used in the signals lab. The laboratory has network licenses
More informationfunction [s p] = sumprod (f, g)
Outline of the Lecture Introduction to M-function programming Matlab Programming Example Relational operators Logical Operators Matlab Flow control structures Introduction to M-function programming M-files:
More informationLECTURE 1. What Is Matlab? Matlab Windows. Help
LECTURE 1 What Is Matlab? Matlab ("MATrix LABoratory") is a software package (and accompanying programming language) that simplifies many operations in numerical methods, matrix manipulation/linear algebra,
More informationLanguage Basics. /* The NUMBER GAME - User tries to guess a number between 1 and 10 */ /* Generate a random number between 1 and 10 */
Overview Language Basics This chapter describes the basic elements of Rexx. It discusses the simple components that make up the language. These include script structure, elements of the language, operators,
More informationMATLAB Lesson I. Chiara Lelli. October 2, Politecnico di Milano
MATLAB Lesson I Chiara Lelli Politecnico di Milano October 2, 2012 MATLAB MATLAB (MATrix LABoratory) is an interactive software system for: scientific computing statistical analysis vector and matrix computations
More informationLEARNING TO PROGRAM WITH MATLAB. Building GUI Tools. Wiley. University of Notre Dame. Craig S. Lent Department of Electrical Engineering
LEARNING TO PROGRAM WITH MATLAB Building GUI Tools Craig S. Lent Department of Electrical Engineering University of Notre Dame Wiley Contents Preface ix I MATLAB Programming 1 1 Getting Started 3 1.1 Running
More informationNumerical Methods for Civil Engineers
Numerical Methods for Civil Engineers Lecture 3 - MATLAB 3 Programming with MATLAB : - Script m-filesm - Function m-filesm - Input and Output - Flow Control Mongkol JIRAVACHARADET S U R A N A R E E UNIVERSITY
More informationAppendix A. Introduction to MATLAB. A.1 What Is MATLAB?
Appendix A Introduction to MATLAB A.1 What Is MATLAB? MATLAB is a technical computing environment developed by The Math- Works, Inc. for computation and data visualization. It is both an interactive system
More informationChapter 3: Introduction to MATLAB Programming (4 th ed.)
Chapter 3: Introduction to MATLAB Programming (4 th ed.) Algorithms MATLAB scripts Input / Output o disp versus fprintf Graphs Read and write variables (.mat files) User-defined Functions o Definition
More informationDr. Khaled Al-Qawasmi
Al-Isra University Faculty of Information Technology Department of CS Programming Mathematics using MATLAB 605351 Dr. Khaled Al-Qawasmi ١ Dr. Kahled Al-Qawasmi 2010-2011 Chapter 3 Selection Statements
More informationUNIT IV 2 MARKS. ( Word to PDF Converter - Unregistered ) FUNDAMENTALS OF COMPUTING & COMPUTER PROGRAMMING
( Word to PDF Converter - Unregistered ) http://www.word-to-pdf-converter.net FUNDAMENTALS OF COMPUTING & COMPUTER PROGRAMMING INTRODUCTION TO C UNIT IV Overview of C Constants, Variables and Data Types
More informationMini-Matlab Lesson 5: Functions and Loops
Mini-Matlab Lesson 5: Functions and Loops Writing Functions and Scripts Contents Relational and logical operators IF loops FOR loops WHILE loops Scripts and functions Defining and using functions Anonymous
More informationChapter 7: Programming in MATLAB
The Islamic University of Gaza Faculty of Engineering Civil Engineering Department Computer Programming (ECIV 2302) Chapter 7: Programming in MATLAB 1 7.1 Relational and Logical Operators == Equal to ~=
More informationSelection Statements
Selection Statements by Ahmet Sacan selection statements, branching statements, condition, relational expression, Boolean expression, logical expression, relational operators, logical operators, truth
More informationImporting and Exporting Data
Class14 Importing and Exporting Data MATLAB is often used for analyzing data that was recorded in experiments or generated by other computer programs. Likewise, data that is produced by MATLAB sometimes
More informationIntroduction to MATLAB
Chapter 1 Introduction to MATLAB 1.1 Software Philosophy Matrix-based numeric computation MATrix LABoratory built-in support for standard matrix and vector operations High-level programming language Programming
More informationStructure Array 1 / 50
Structure Array A structure array is a data type that groups related data using data containers called fields. Each field can contain any type of data. Access data in a structure using dot notation of
More informationIntroduction to Octave/Matlab. Deployment of Telecommunication Infrastructures
Introduction to Octave/Matlab Deployment of Telecommunication Infrastructures 1 What is Octave? Software for numerical computations and graphics Particularly designed for matrix computations Solving equations,
More informationMatlab Input/Output. Goal of this section Learn user-controlled Input Output Read/write data files (optional) Input/output 5-
Matlab Input/Output Goal of this section Learn user-controlled Input Output Read/write data files (optional) 85-232 Input/output 5-1 Input: initialization >> a=[-1 0 0 ; 1 1 0] >> b=[1, 2, 3; 2:4] >> b=[1,
More informationAssoc. Prof. Dr. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved.
Assoc. Prof. Dr. Marenglen Biba (C) 2010 Pearson Education, Inc. All rights reserved. Java application A computer program that executes when you use the java command to launch the Java Virtual Machine
More informationIntroduction to MATLAB LAB 1
Introduction to MATLAB LAB 1 1 Basics of MATLAB MATrix LABoratory A super-powerful graphing calculator Matrix based numeric computation Embedded Functions Also a programming language User defined functions
More informationEL2310 Scientific Programming
Lecture 7: Introduction to C (pronobis@kth.se) Overview Overview Lecture 7: Introduction to C Wrap Up Basic Datatypes and printf Branching and Loops in C Constant values Wrap Up Lecture 7: Introduction
More informationMATLAB Introductory Course Computer Exercise Session
MATLAB Introductory Course Computer Exercise Session This course is a basic introduction for students that did not use MATLAB before. The solutions will not be collected. Work through the course within
More informationProgramming in MATLAB
8. Program Flow and Recursion Faculty of mathematics, physics and informatics Comenius University in Bratislava November 25th, 2015 Program Flow Program Flow in the first lecture: one command at a time
More informationOrdinary Differential Equation Solver Language (ODESL) Reference Manual
Ordinary Differential Equation Solver Language (ODESL) Reference Manual Rui Chen 11/03/2010 1. Introduction ODESL is a computer language specifically designed to solve ordinary differential equations (ODE
More informationUNIT- 3 Introduction to C++
UNIT- 3 Introduction to C++ C++ Character Sets: Letters A-Z, a-z Digits 0-9 Special Symbols Space + - * / ^ \ ( ) [ ] =!= . $, ; : %! &? _ # = @ White Spaces Blank spaces, horizontal tab, carriage
More informationDr Richard Greenaway
SCHOOL OF PHYSICS, ASTRONOMY & MATHEMATICS 4PAM1008 MATLAB 2 Basic MATLAB Operation Dr Richard Greenaway 2 Basic MATLAB Operation 2.1 Overview 2.1.1 The Command Line In this Workshop you will learn how
More informationOutline. User-based knn Algorithm Basics of Matlab Control Structures Scripts and Functions Help
Outline User-based knn Algorithm Basics of Matlab Control Structures Scripts and Functions Help User-based knn Algorithm Three main steps Weight all users with respect to similarity with the active user.
More informationSECTION 2: PROGRAMMING WITH MATLAB. MAE 4020/5020 Numerical Methods with MATLAB
SECTION 2: PROGRAMMING WITH MATLAB MAE 4020/5020 Numerical Methods with MATLAB 2 Functions and M Files M Files 3 Script file so called due to.m filename extension Contains a series of MATLAB commands The
More informationLesson 2 Characteristics of Good Code Writing (* acknowledgements to Dr. G. Spinelli, New Mexico Tech, for a substantial portion of this lesson)
T-01-13-2009 GLY 6932/6862 Numerical Methods in Earth Sciences Spring 2009 Lesson 2 Characteristics of Good Code Writing (* acknowledgements to Dr. G. Spinelli, New Mexico Tech, for a substantial portion
More informationStarting with a great calculator... Variables. Comments. Topic 5: Introduction to Programming in Matlab CSSE, UWA
Starting with a great calculator... Topic 5: Introduction to Programming in Matlab CSSE, UWA! MATLAB is a high level language that allows you to perform calculations on numbers, or arrays of numbers, in
More informationIntroduction to MATLAB
Introduction to MATLAB 1 Introduction to MATLAB A Tutorial for the Course Computational Intelligence http://www.igi.tugraz.at/lehre/ci Stefan Häusler Institute for Theoretical Computer Science Inffeldgasse
More informationMATLAB BASICS. < Any system: Enter quit at Matlab prompt < PC/Windows: Close command window < To interrupt execution: Enter Ctrl-c.
MATLAB BASICS Starting Matlab < PC: Desktop icon or Start menu item < UNIX: Enter matlab at operating system prompt < Others: Might need to execute from a menu somewhere Entering Matlab commands < Matlab
More informationIT 374 C# and Applications/ IT695 C# Data Structures
IT 374 C# and Applications/ IT695 C# Data Structures Module 2.1: Introduction to C# App Programming Xianrong (Shawn) Zheng Spring 2017 1 Outline Introduction Creating a Simple App String Interpolation
More informationLinear algebra & Numerical Analysis
Linear algebra & Numerical Analysis Introduction to MATLAB Marta Jarošová http://homel.vsb.cz/~dom033/ Outline What is it MATLAB? MATLAB Environment and MATLAB Help Variables, matrices and vectors Strings.m
More informationScalars and Variables
Chapter 2 Scalars and Variables In this chapter, we will discuss arithmetic operations with scalars (numbers, really an array with only one element) and variables. Scalars can be used directly in calculations
More informationIntroduction to Julia. HA Van Thao Faculty of Math & Computer Science, HCMUS
Introduction to Julia HA Van Thao Faculty of Math & Computer Science, HCMUS What is Julia? a new programming language for scientic computing developed by a group mostly from MIT MIT licensed: free and
More informationJME Language Reference Manual
JME Language Reference Manual 1 Introduction JME (pronounced jay+me) is a lightweight language that allows programmers to easily perform statistic computations on tabular data as part of data analysis.
More informationIntroduction to MATLAB Programming
Spring 2019 Spring 2019 1 / 17 Introduction Algorithm An algorithm is a sequence of steps needed to solve a problem. We will use MATLAB to develop algorithms to solve specific problems. The basic algorithm
More informationMATLAB Tutorial. Mohammad Motamed 1. August 28, generates a 3 3 matrix.
MATLAB Tutorial 1 1 Department of Mathematics and Statistics, The University of New Mexico, Albuquerque, NM 87131 August 28, 2016 Contents: 1. Scalars, Vectors, Matrices... 1 2. Built-in variables, functions,
More informationMatLab Just a beginning
MatLab Just a beginning P.Kanungo Dept. of E & TC, C.V. Raman College of Engineering, Bhubaneswar Introduction MATLAB is a high-performance language for technical computing. MATLAB is an acronym for MATrix
More informationC++ Basics. Lecture 2 COP 3014 Spring January 8, 2018
C++ Basics Lecture 2 COP 3014 Spring 2018 January 8, 2018 Structure of a C++ Program Sequence of statements, typically grouped into functions. function: a subprogram. a section of a program performing
More informationScientific Computing with MATLAB
Scientific Computing with MATLAB Dra. K.-Y. Daisy Fan Department of Computer Science Cornell University Ithaca, NY, USA UNAM IIM 2012 2 Focus on computing using MATLAB Computer Science Computational Science
More informationChapter 2 - Introduction to C Programming
Chapter 2 - Introduction to C Programming 2 Outline 2.1 Introduction 2.2 A Simple C Program: Printing a Line of Text 2.3 Another Simple C Program: Adding Two Integers 2.4 Memory Concepts 2.5 Arithmetic
More informationMAE10 Midterm Examination II Winter Quarter 2010
MAE10 Midterm Examination II Winter Quarter 2010 Instructions: You have 90 minutes to complete the exam. Notes on two sides of an 8.5 x11 sheet of paper are allowed. Closed book. No calculators or electronic
More informationMaciej Sobieraj. Lecture 1
Maciej Sobieraj Lecture 1 Outline 1. Introduction to computer programming 2. Advanced flow control and data aggregates Your first program First we need to define our expectations for the program. They
More informationRelational & Logical Operators, Selection Statements
Relational & Logical Operators, Selection Statements by Ahmet Sacan selection statements, branching statements, condition, relational expression, Boolean expression, logical expression, relational operators,
More informationCOGS 119/219 MATLAB for Experimental Research. Fall 2016 Week 1 Built-in array functions, Data types.m files, begin Flow Control
COGS 119/219 MATLAB for Experimental Research Fall 2016 Week 1 Built-in array functions, Data types.m files, begin Flow Control .m files We can write the MATLAB commands that we type at the command window
More informationELEC4042 Signal Processing 2 MATLAB Review (prepared by A/Prof Ambikairajah)
Introduction ELEC4042 Signal Processing 2 MATLAB Review (prepared by A/Prof Ambikairajah) MATLAB is a powerful mathematical language that is used in most engineering companies today. Its strength lies
More information21-Loops Part 2 text: Chapter ECEGR 101 Engineering Problem Solving with Matlab Professor Henry Louie
21-Loops Part 2 text: Chapter 6.4-6.6 ECEGR 101 Engineering Problem Solving with Matlab Professor Henry Louie While Loop Infinite Loops Break and Continue Overview Dr. Henry Louie 2 WHILE Loop Used to
More informationLinear Algebra and MATLAB
Linear Algebra and MATLAB Pre-Semester Course Mathematics Christian Seckinger Christian.Seckinger@hof.uni-frankfurt.de MATLAB 1 1 This script is based on a MATLAB course of Alexey Cherepnev and Tobias
More information