Lab 4 CSE 7, Spring 2018 This lab is an introduction to using logical and comparison operators in Matlab.

Size: px
Start display at page:

Download "Lab 4 CSE 7, Spring 2018 This lab is an introduction to using logical and comparison operators in Matlab."

Transcription

1 LEARNING OBJECTIVES: Lab 4 CSE 7, Spring 2018 This lab is an introduction to using logical and comparison operators in Matlab 1 Use comparison operators (< > <= >= == ~=) between two scalar values to create a logical value 2 Use comparison operators between a scalar and a matrix to create a matrix of logical values 3 Use matrix of logical values to index a matrix (eg select only certain pixels of an RGB image) 4 Use logical operators to combine logical expressions into compound expressions 5 Use cat() function 6 Review: o Define your own functions o Explore RGB image matrices in MATLAB o Perform advanced indexing and manipulations of RGB image matrices REMINDER: You may ask the course TA and Tutors for assistance You must complete this assignment without looking at other student s code or copying solutions from any source DESCRIPTION: In this assignment, you will both report on outcomes of different experiments, and save your MATLAB code and image as a file for turn in LAB INSTRUCTIONS: Login and set up same environment as Lab#1 (cs7sxx ieng6 home directory, Notepad++, MATLAB) Refer to Lab#1 PART ONE: REVIEW WRITING FUNCTIONS 1 Functions allow you to split code into smaller segments that are each easily understood In previous homework (HW#3), we learned how to write simple functions of our own Let us revisit what we learned 2 General Syntax of a MATLAB Function: function [outvalue1, outvalue2,, outvaluen ] = functionname (invalue1, invalue2,, invaluen) % First comment line - here you should describe what your function does % Additional lines of comments MATLAB commands end

2 3 Understanding the Syntax: Keyword: MATLAB functions must begin with the keyword "function" and end with the keyword end" o end terminates the function o function shows the outputs, name and input arguments of the function Output: MATLAB supports multiple output values, listed as shown in square brackets o If a function only has a single output, then the square brackets are not required o If a function does not have any output, then neither the square brackets nor the equals sign that follows are used Name: The name of the function must match the name of the m file containing the function Input: Matlab supports multiple input values, in a comma separated list within parentheses as shown o If a function takes no input values, the empty parentheses are still required * Question #1: How would the header of the function look for a function with 2 outputs and 1 input argument? No outputs and 1 input argument? 1 output and no input argument? 4 Let us now write a simple function named calctrianglearea that does the following: takes two scalar input values: b and h, representing the base and height of a triangle has one output value: area calculates the area of triangle using the given base and height store the area in output variable area 5 Once you've written the function, save the file by clicking the Save button in the Editor tab Because the filename must match the function name, you should save the file as calctriangleaream Once the file is saved, we can try calling our new function on the command line just as we would try any other built-in function: >> calctrianglearea(2, 5) Question #2: Copy and paste your entire function, including all comments, into your lab document PART TWO: INTRODUCTION TO CONDITIONALS 1 So far we have seen a number of arithmetic expressions using operators such as +, and * We can also create logical or conditional expressions using comparison and logical operators Such expressions always produce a numerical result that is either 1 for true expressions, or 0 for false expressions 2 The comparison operators are: < (less than) <= (less than or equal to) == (equal to) The Boolean operators are: >= (greater than or equal to) > (greater than) ~= (not equal to) & (and) && (and with short-circuiting) (or) ~ (not) Just like with arithmetic operators, you can use parentheses to bracket expressions to force an evaluation order For example, try typing these following example expressions on the command line: * Note: in Matlab version 2017b, empty parenthesis is not required for no input arguments

3 >> x = 120; >> y = 20; >> disp ( x < y); >> disp ( x < 110); >> disp ( (x > 29) & (y < 30)); >> disp((x ~= 0 ) (y > 80)); >> disp( ~(x < 24)); >> z = (x ~= y); Question #3: Copy and paste the results of these expression into your lab document Question #4: What is the value of z after you typed in z=(x==y)? Explain why you get this value Question #5: Explain what is going on in the line disp((x ~= 0) (y >80)); Explain what are the conditionals doing as well as the what the disp function does (Hint: use the help disp command) PART THREE: IMAGE MASHING USING CONDITIONALS 1 Now onto some fun stuff! Let's start by playing around with some green screen code To start with, save the following three images ( mariojpg, librarywalkjpg, originaljpg ) into your MATLAB directory 2

4 3 Load these 3 images into different MATLAB RGB matrices: (replace??? with correct code) mario = imread(???); original = imread(???); librarywalk = imread(???); %read in the second file and make sure it matches variable name %read in the third file 4 Now we need to put Mario in the original game Begin by creating a filter that masks out the green areas of the image using conditionals on the layers of the image filter = mario (:,:,1)<??? & mario (:,:,2)>??? & mario (:,:,3)<???; We've given you most of the code above but you will have to replace the remaining??? with appropriate values (it's ok to look at the lecture slides for help, but to test your learning you might try to puzzle it out yourself first) Remember we want this filter to select the background areas which are close to green Hint: First try replacing all??? with some numbers between 0 and 255 and see what happens It may take a few tries to get it right, so just keep playing with the values and remember what they represent Question #6: Explain what happens if you replace??? with 0 or 255? 5 So we have gathered all the pixel values that are close to green and stored them in a twodimensional matrix called filter This 2-D matrix will only have the logical values of either 0 or 1 6 Type imshow(filter) in the command window to see your filter We selected the green background around Mario to replace it with our 'original' background (the white space in the filter picture below) But Mario himself is in black because he is not green 7 You are not done yet! Let's use the filter to make Mario run in the game background 8 Next we want to create a new image based on this filter, however, notice that the filter we made has just one "layer" while the images have 3: Question #7: Describe in your words what does each layer in the image represent?

5 9 Since we want to use this on RGB images, we need fix this by duplicating the filter 3 times This can be done by the command: 10 The cat function takes matrices and combines them into one matrix The "3" in input arguments means that these should be combined (layered) in the third dimension (ie the layer dimension--- the 1st dimension is rows, the 2nd is columns) You don't need to deeply understand the cat function for this class, but you should get used to using this line of code, which we will use often to create RGB filters 11 Finally, we are ready to create our new image We create a mashup image by first copying all the information from mario Then, we copy in values from the original background indexed by our filter: mashup = mario; mashup(filter) = original(filter); imshow(mashup) 12 Previously we have done matrix indexing that looked like this: mashup(1:end,1:2:end, : ) That code selects only certain rows and columns of the image (in this example: every row, every other column, and all layers) The line above that includes mashup(filter) is also doing matrix indexing! But it copies only certain individual pixels instead of certain rows/columns The pixels it selects are the ones where filter has a 1 value, not a 0 Question #8: State the final values you picked for the??? parts in the filter and why 13 If you had chosen your values for the??? parts correctly above, this should result in an image resembling: Mario in original game looks like this! It s ok if you have some green on the edge of the mario If you have too much green, feel free to go back and change your values Just remember to redo all the steps again (ie using cat on filter, redoing the filter on mashup, etc)

6 14 Save the image above as mashupjpg Show this image during check-off 15 Now, let s make Mario run on Library Walk!! Remember to replace??? with the correct code mashup = mario; mashup(filter) = (???)(filter); imshow(mashup); Hint: Refer back to how we did the first mashup Which variable name was in the place of the???? So which variable name should we use this time? What is its role and what is this line of code doing? 16 Question #9: Copy and paste your code Explain what you replaced??? with and why 17 Save the image as moremashupjpg Show this image during check-off 18 If you've done it correctly, Mario should be running in UCSD: Mario on library walk looks like this! 19 PART FOUR: ERROR CHECKING WITH CONDITIONALS Changing gears now, we'll examine using conditionals to check for things that could cause MATLAB errors so we can avoid those errors in our code In particular, we'll look at checking matrix index boundaries (to make sure we don't get an error by indexing our matrix out-of-bounds 1 Start by creating a variable x and matrix A with The function magic(7) creates a special matrix with the property that all the rows and columns sum to the same thing (a little bit like Sudoku, but not exactly) If you typed the above command WITHOUT the semicolon, as shown above, you should see the values of the matrix and you can take a moment to check that the sum property is true Remember you can also double-click on the matrix name (A) in the Workspace pane at any time to see all the values in A

7 2 Let's use MATLAB to check that the sum property is true Try executing these two lines of code: The first line checks if row x sums to 175 and the second checks if column x sums to 175 Both should evaluate to true (1) You could also just type "sum(a(2,: )) == 175" of course! But we're using x for a reason you'll see in a minute Try this with a few different values of x to check other rows and other columns: This all works well assuming x is a valid value What happens if we set x = 0 and then try to evaluate the above sums? What about x = 8? Question #10: Describe the errors you get and explain what is happening We would like to add some conditional code to make sure that x is in a valid range A possibility might be An interesting thing you may not be aware of yet is that you can also use && to mean "and" test, just like & Even though they both mean "and" test, they work slightly differently Try this: One of these two versions of this conditional code results in an error Question #11: State which one results in an error and explain why What is the difference between & and && [HINT: It has to do with short-circuiting ]?

8 PART THREE: LAB #4 CHECKOFF CHECKLIST To receive credit for this lab you need to: Write your name on the whiteboard, when you are finished Show your TA/Tutor your Notepad++ document in your ieng6 cs7sxx home directory folder Be prepared to show the TA/Tutor all questions sufficiently answered in this document Be prepared to show the TA/Tutor the 2 images you were asked to save mashupjpg moremashupjpg Be able to answer questions about the MATLAB environment, functions, documentation and more Do not leave until you received an autograder confirming that you have received credit It is your responsibility to make sure you get credit for each lab!

Homework #2: Introduction to Images Due 4 th Week of Spring 2018 at the start of lab CSE 7, Spring 2018

Homework #2: Introduction to Images Due 4 th Week of Spring 2018 at the start of lab CSE 7, Spring 2018 Homework #2: Introduction to Images Due 4 th Week of Spring 2018 at the start of lab CSE 7, Spring 2018 Before beginning this homework, create a new Notepad++ file in your cs7sxx home directory on ieng6

More information

Slide 1 CS 170 Java Programming 1 Testing Karel

Slide 1 CS 170 Java Programming 1 Testing Karel CS 170 Java Programming 1 Testing Karel Introducing Unit Tests to Karel's World Slide 1 CS 170 Java Programming 1 Testing Karel Hi Everybody. This is the CS 170, Java Programming 1 lecture, Testing Karel.

More information

CS1114: Matlab Introduction

CS1114: Matlab Introduction CS1114: Matlab Introduction 1 Introduction The purpose of this introduction is to provide you a brief introduction to the features of Matlab that will be most relevant to your work in this course. Even

More information

Homework #1: SSH. Step 1: From the start button (lower left hand corner) type Secure. Then click on the Secure Shell File Transfer Client.

Homework #1: SSH. Step 1: From the start button (lower left hand corner) type Secure. Then click on the Secure Shell File Transfer Client. Homework #1: SSH Due WEEK 3 at the BEGINNING of lab CSE 3, Spring 2018 A. The program Some students had trouble using this program in the past. It isn t too bad if you just take a few minutes to read and

More information

Digital Image Processing

Digital Image Processing Digital Image Processing Introduction to MATLAB Hanan Hardan 1 Background on MATLAB (Definition) MATLAB is a high-performance language for technical computing. The name MATLAB is an interactive system

More information

APPM 2460 Matlab Basics

APPM 2460 Matlab Basics APPM 2460 Matlab Basics 1 Introduction In this lab we ll get acquainted with the basics of Matlab. This will be review if you ve done any sort of programming before; the goal here is to get everyone on

More information

Computer Vision. Matlab

Computer Vision. Matlab Computer Vision Matlab A good choice for vision program development because Easy to do very rapid prototyping Quick to learn, and good documentation A good library of image processing functions Excellent

More information

CS100R: Matlab Introduction

CS100R: Matlab Introduction CS100R: Matlab Introduction August 25, 2007 1 Introduction The purpose of this introduction is to provide you a brief introduction to the features of Matlab that will be most relevant to your work in this

More information

MATLAB Demo. Preliminaries and Getting Started with Matlab

MATLAB Demo. Preliminaries and Getting Started with Matlab Math 250C Sakai submission Matlab Demo 1 Created by G. M. Wilson, revised 12/23/2015 Revised 09/05/2016 Revised 01/07/2017 MATLAB Demo In this lab, we will learn how to use the basic features of Matlab

More information

Matlab notes Matlab is a matrix-based, high-performance language for technical computing It integrates computation, visualisation and programming usin

Matlab notes Matlab is a matrix-based, high-performance language for technical computing It integrates computation, visualisation and programming usin Matlab notes Matlab is a matrix-based, high-performance language for technical computing It integrates computation, visualisation and programming using familiar mathematical notation The name Matlab stands

More information

function [s p] = sumprod (f, g)

function [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 information

Data Classes & Objects and CSV Processing. Lecture 8 - Spring COMP110

Data Classes & Objects and CSV Processing. Lecture 8 - Spring COMP110 Data Classes & Objects and CSV Processing Lecture 8 - Spring 2018 - COMP110 Announcements WS02 Due Friday at 11:59pm Review Session Tomorrow (Wednesday) at 5pm in SN014 Uncertain with topics from the last

More information

Constraint-based Metabolic Reconstructions & Analysis H. Scott Hinton. Matlab Tutorial. Lesson: Matlab Tutorial

Constraint-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 information

Homework 09. Collecting Beepers

Homework 09. Collecting Beepers Homework 09 Collecting Beepers Goal In this lab assignment, you will be writing a simple Java program to create a robot object called karel. Your robot will start off in a world containing a series of

More information

EGR 102 Introduction to Engineering Modeling. Lab 05A Managing Data

EGR 102 Introduction to Engineering Modeling. Lab 05A Managing Data EGR 102 Introduction to Engineering Modeling Lab 05A Managing Data 1 Overview Review Structured vectors in MATLAB Creating Vectors/arrays:» Linspace» Colon operator» Concatenation Initializing variables

More information

CS1114: Matlab Introduction

CS1114: Matlab Introduction CS1114: Matlab Introduction 1 Introduction The purpose of this introduction is to provide you a brief introduction to the features of Matlab that will be most relevant to your work in this course. Even

More information

Slide 1 CS 170 Java Programming 1 Multidimensional Arrays Duration: 00:00:39 Advance mode: Auto

Slide 1 CS 170 Java Programming 1 Multidimensional Arrays Duration: 00:00:39 Advance mode: Auto CS 170 Java Programming 1 Working with Rows and Columns Slide 1 CS 170 Java Programming 1 Duration: 00:00:39 Create a multidimensional array with multiple brackets int[ ] d1 = new int[5]; int[ ][ ] d2;

More information

MATLAB Programming for Numerical Computation Dr. Niket Kaisare Department Of Chemical Engineering Indian Institute of Technology, Madras

MATLAB Programming for Numerical Computation Dr. Niket Kaisare Department Of Chemical Engineering Indian Institute of Technology, Madras MATLAB Programming for Numerical Computation Dr. Niket Kaisare Department Of Chemical Engineering Indian Institute of Technology, Madras Module No. #01 Lecture No. #1.1 Introduction to MATLAB programming

More information

Introduction to Scientific Computing with Matlab

Introduction to Scientific Computing with Matlab UNIVERSITY OF WATERLOO Introduction to Scientific Computing with Matlab SAW Training Course R. William Lewis Computing Consultant Client Services Information Systems & Technology 2007 Table of Contents

More information

CMSC 201 Spring 2017 Homework 4 Lists (and Loops and Strings)

CMSC 201 Spring 2017 Homework 4 Lists (and Loops and Strings) CMSC 201 Spring 2017 Homework 4 Lists (and Loops and Strings) Assignment: Homework 4 Lists (and Loops and Strings) Due Date: Friday, March 3rd, 2017 by 8:59:59 PM Value: 40 points Collaboration: For Homework

More information

MATLIP: MATLAB-Like Language for Image Processing

MATLIP: MATLAB-Like Language for Image Processing COMS W4115: Programming Languages and Translators MATLIP: MATLAB-Like Language for Image Processing Language Reference Manual Pin-Chin Huang (ph2249@columbia.edu) Shariar Zaber Kazi (szk2103@columbia.edu)

More information

Ordinary Differential Equation Solver Language (ODESL) Reference Manual

Ordinary 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 information

Introduction to MATLAB

Introduction 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 information

EN 001-4: Introduction to Computational Design. Matrices & vectors. Why do we care about vectors? What is a matrix and a vector?

EN 001-4: Introduction to Computational Design. Matrices & vectors. Why do we care about vectors? What is a matrix and a vector? EN 001-: Introduction to Computational Design Fall 2017 Tufts University Instructor: Soha Hassoun soha@cs.tufts.edu Matrices & vectors Matlab is short for MATrix LABoratory. In Matlab, pretty much everything

More information

Spring CS Homework 3 p. 1. CS Homework 3

Spring CS Homework 3 p. 1. CS Homework 3 Spring 2018 - CS 111 - Homework 3 p. 1 Deadline 11:59 pm on Friday, February 9, 2018 Purpose CS 111 - Homework 3 To try out another testing function, check-within, to get more practice using the design

More information

STAT 540 Computing in Statistics

STAT 540 Computing in Statistics STAT 540 Computing in Statistics Introduces programming skills in two important statistical computer languages/packages. 30-40% R and 60-70% SAS Examples of Programming Skills: 1. Importing Data from External

More information

MATLAB COURSE FALL 2004 SESSION 1 GETTING STARTED. Christian Daude 1

MATLAB COURSE FALL 2004 SESSION 1 GETTING STARTED. Christian Daude 1 MATLAB COURSE FALL 2004 SESSION 1 GETTING STARTED Christian Daude 1 Introduction MATLAB is a software package designed to handle a broad range of mathematical needs one may encounter when doing scientific

More information

MATLAB Introduction to MATLAB Programming

MATLAB 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 information

MATLAB - Lecture # 4

MATLAB - Lecture # 4 MATLAB - Lecture # 4 Script Files / Chapter 4 Topics Covered: 1. Script files. SCRIPT FILE 77-78! A script file is a sequence of MATLAB commands, called a program.! When a file runs, MATLAB executes the

More information

Introduction to Programming in C Department of Computer Science and Engineering. Lecture No. #43. Multidimensional Arrays

Introduction to Programming in C Department of Computer Science and Engineering. Lecture No. #43. Multidimensional Arrays Introduction to Programming in C Department of Computer Science and Engineering Lecture No. #43 Multidimensional Arrays In this video will look at multi-dimensional arrays. (Refer Slide Time: 00:03) In

More information

LAB 7 Writing Assembly Code

LAB 7 Writing Assembly Code Goals To Do LAB 7 Writing Assembly Code Learn to program a processor at the lowest level. Implement a program that will be used to test your own MIPS processor. Understand different addressing modes of

More information

EOSC 352 MATLAB Review

EOSC 352 MATLAB Review EOSC 352 MATLAB Review To use MATLAB, you can either (1) type commands in the window (i.e., at the command line ) or (2) type in the name of a file you have made, whose name ends in.m and which contains

More information

implementing the breadth-first search algorithm implementing the depth-first search algorithm

implementing the breadth-first search algorithm implementing the depth-first search algorithm Graph Traversals 1 Graph Traversals representing graphs adjacency matrices and adjacency lists 2 Implementing the Breadth-First and Depth-First Search Algorithms implementing the breadth-first search algorithm

More information

1 Overview of the standard Matlab syntax

1 Overview of the standard Matlab syntax 1 Overview of the standard Matlab syntax Matlab is based on computations with matrices. All variables are matrices. Matrices are indexed from 1 (and NOT from 0 as in C!). Avoid using variable names i and

More information

EXAM Computer Science 1 Part 1

EXAM Computer Science 1 Part 1 Maastricht University Faculty of Humanities and Science Department of Knowledge Engineering EXAM Computer Science 1 Part 1 Block 1.1: Computer Science 1 Code: KEN1120 Examiner: Kurt Driessens Date: Januari

More information

17 USING THE EDITOR AND CREATING PROGRAMS AND FUNCTIONS

17 USING THE EDITOR AND CREATING PROGRAMS AND FUNCTIONS 17 USING THE EDITOR AND CREATING PROGRAMS AND FUNCTIONS % Programs are kept in an m-file which is a series of commands kept in the file that is executed from MATLAB by typing the program (file) name from

More information

Matlab for FMRI Module 1: the basics Instructor: Luis Hernandez-Garcia

Matlab for FMRI Module 1: the basics Instructor: Luis Hernandez-Garcia Matlab for FMRI Module 1: the basics Instructor: Luis Hernandez-Garcia The goal for this tutorial is to make sure that you understand a few key concepts related to programming, and that you know the basics

More information

Day 1: Introduction to MATLAB and Colorizing Images CURIE Academy 2015: Computational Photography Sign-Off Sheet

Day 1: Introduction to MATLAB and Colorizing Images CURIE Academy 2015: Computational Photography Sign-Off Sheet Day 1: Introduction to MATLAB and Colorizing Images CURIE Academy 2015: Computational Photography Sign-Off Sheet NAME: NAME: Part 1.1 Part 1.2 Part 1.3 Part 2.1 Part 2.2 Part 3.1 Part 3.2 Sign-Off Milestone

More information

1 Introduction to Matlab

1 Introduction to Matlab 1 Introduction to Matlab 1. What is Matlab? Matlab is a computer program designed to do mathematics. You might think of it as a super-calculator. That is, once Matlab has been started, you can enter computations,

More information

Boolean Logic & Branching Lab Conditional Tests

Boolean Logic & Branching Lab Conditional Tests I. Boolean (Logical) Operations Boolean Logic & Branching Lab Conditional Tests 1. Review of Binary logic Three basic logical operations are commonly used in binary logic: and, or, and not. Table 1 lists

More information

Lab of COMP 406. MATLAB: Quick Start. Lab tutor : Gene Yu Zhao Mailbox: or Lab 1: 11th Sep, 2013

Lab of COMP 406. MATLAB: Quick Start. Lab tutor : Gene Yu Zhao Mailbox: or Lab 1: 11th Sep, 2013 Lab of COMP 406 MATLAB: Quick Start Lab tutor : Gene Yu Zhao Mailbox: csyuzhao@comp.polyu.edu.hk or genexinvivian@gmail.com Lab 1: 11th Sep, 2013 1 Where is Matlab? Find the Matlab under the folder 1.

More information

CSE 115. Introduction to Computer Science I

CSE 115. Introduction to Computer Science I CSE 115 Introduction to Computer Science I Announcements Lab activites/lab exams submit regularly to autograder.cse.buffalo.edu Announcements Lab activites/lab exams submit regularly to autograder.cse.buffalo.edu

More information

Matlab- Command Window Operations, Scalars and Arrays

Matlab- Command Window Operations, Scalars and Arrays 1 ME313 Homework #1 Matlab- Command Window Operations, Scalars and Arrays Last Updated August 17 2012. Assignment: Read and complete the suggested commands. After completing the exercise, copy the contents

More information

Introduction to MATLAB

Introduction to MATLAB Introduction to MATLAB Introduction: MATLAB is a powerful high level scripting language that is optimized for mathematical analysis, simulation, and visualization. You can interactively solve problems

More information

Dr Richard Greenaway

Dr Richard Greenaway SCHOOL OF PHYSICS, ASTRONOMY & MATHEMATICS 4PAM1008 MATLAB 3 Creating, Organising & Processing Data Dr Richard Greenaway 3 Creating, Organising & Processing Data In this Workshop the matrix type is introduced

More information

MAT 343 Laboratory 1 Matrix and Vector Computations in MATLAB

MAT 343 Laboratory 1 Matrix and Vector Computations in MATLAB MAT 343 Laboratory 1 Matrix and Vector Computations in MATLAB In this laboratory session we will learn how to 1. Create matrices and vectors. 2. Manipulate matrices and create matrices of special types

More information

MATLAB: The Basics. Dmitry Adamskiy 9 November 2011

MATLAB: The Basics. Dmitry Adamskiy 9 November 2011 MATLAB: The Basics Dmitry Adamskiy adamskiy@cs.rhul.ac.uk 9 November 2011 1 Starting Up MATLAB Windows users: Start up MATLAB by double clicking on the MATLAB icon. Unix/Linux users: Start up by typing

More information

Getting started with MATLAB

Getting started with MATLAB Getting started with MATLAB You can work through this tutorial in the computer classes over the first 2 weeks, or in your own time. The Farber and Goldfarb computer classrooms have working Matlab, but

More information

Lab - 8 Awk Programming

Lab - 8 Awk Programming Lab - 8 Awk Programming AWK is another interpreted programming language which has powerful text processing capabilities. It can solve complex text processing tasks with a few lines of code. Listed below

More information

The Warhol Language Reference Manual

The Warhol Language Reference Manual The Warhol Language Reference Manual Martina Atabong maa2247 Charvinia Neblett cdn2118 Samuel Nnodim son2105 Catherine Wes ciw2109 Sarina Xie sx2166 Introduction Warhol is a functional and imperative programming

More information

TUTORIAL MATLAB OPTIMIZATION TOOLBOX

TUTORIAL MATLAB OPTIMIZATION TOOLBOX TUTORIAL MATLAB OPTIMIZATION TOOLBOX INTRODUCTION MATLAB is a technical computing environment for high performance numeric computation and visualization. MATLAB integrates numerical analysis, matrix computation,

More information

Step 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 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 information

Semester 2, 2018: Lab 1

Semester 2, 2018: Lab 1 Semester 2, 2018: Lab 1 S2 2018 Lab 1 This lab has two parts. Part A is intended to help you familiarise yourself with the computing environment found on the CSIT lab computers which you will be using

More information

1 Getting started with Processing

1 Getting started with Processing cis3.5, spring 2009, lab II.1 / prof sklar. 1 Getting started with Processing Processing is a sketch programming tool designed for use by non-technical people (e.g., artists, designers, musicians). For

More information

MATLAB Basics. Configure a MATLAB Package 6/7/2017. Stanley Liang, PhD York University. Get a MATLAB Student License on Matworks

MATLAB Basics. Configure a MATLAB Package 6/7/2017. Stanley Liang, PhD York University. Get a MATLAB Student License on Matworks MATLAB Basics Stanley Liang, PhD York University Configure a MATLAB Package Get a MATLAB Student License on Matworks Visit MathWorks at https://www.mathworks.com/ It is recommended signing up with a student

More information

contain a geometry package, and so on). All Java classes should belong to a package, and you specify that package by typing:

contain a geometry package, and so on). All Java classes should belong to a package, and you specify that package by typing: Introduction to Java Welcome to the second CS15 lab! By now we've gone over objects, modeling, properties, attributes, and how to put all of these things together into Java classes. It's perfectly okay

More information

Loopy stuff: for loops

Loopy stuff: for loops R Programming Week 3 : Intro to Loops Reminder: Some of the exercises below require you to have mastered (1) the use of the cat function, and (2) the use of the source function. Loopy stuff: for loops

More information

Starting Matlab. MATLAB Laboratory 09/09/10 Lecture. Command Window. Drives/Directories. Go to.

Starting Matlab. MATLAB Laboratory 09/09/10 Lecture. Command Window. Drives/Directories. Go to. Starting Matlab Go to MATLAB Laboratory 09/09/10 Lecture Lisa A. Oberbroeckling Loyola University Maryland loberbroeckling@loyola.edu http://ctx.loyola.edu and login with your Loyola name and password...

More information

Lesson 5C MyClass Methods. By John B. Owen All rights reserved 2011, revised 2014

Lesson 5C MyClass Methods. By John B. Owen All rights reserved 2011, revised 2014 Lesson 5C MyClass Methods By John B. Owen All rights reserved 2011, revised 2014 Table of Contents Objectives Defining your own class Defining and calling a static method Method structure String return

More information

Teaching Manual Math 2131

Teaching Manual Math 2131 Math 2131 Linear Algebra Labs with MATLAB Math 2131 Linear algebra with Matlab Teaching Manual Math 2131 Contents Week 1 3 1 MATLAB Course Introduction 5 1.1 The MATLAB user interface...........................

More information

MAT 275 Laboratory 2 Matrix Computations and Programming in MATLAB

MAT 275 Laboratory 2 Matrix Computations and Programming in MATLAB MAT 75 Laboratory Matrix Computations and Programming in MATLAB In this laboratory session we will learn how to. Create and manipulate matrices and vectors.. Write simple programs in MATLAB NOTE: For your

More information

ENGR 1181 MATLAB 09: For Loops 2

ENGR 1181 MATLAB 09: For Loops 2 ENGR 1181 MATLAB 09: For Loops Learning Objectives 1. Use more complex ways of setting the loop index. Construct nested loops in the following situations: a. For use with two dimensional arrays b. For

More information

INTRODUCTION TO LABVIEW

INTRODUCTION TO LABVIEW INTRODUCTION TO LABVIEW 2nd Year Microprocessors Laboratory 2012-2013 INTRODUCTION For the first afternoon in the lab you will learn to program using LabVIEW. This handout is designed to give you an introduction

More information

In the first class, you'll learn how to create a simple single-view app, following a 3-step process:

In the first class, you'll learn how to create a simple single-view app, following a 3-step process: Class 1 In the first class, you'll learn how to create a simple single-view app, following a 3-step process: 1. Design the app's user interface (UI) in Xcode's storyboard. 2. Open the assistant editor,

More information

Introduction to MATLAB LAB 1

Introduction 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 information

Introduction to Matlab

Introduction to Matlab Introduction to Matlab Outline: What is Matlab? Matlab Screen Variables, array, matrix, indexing Operators (Arithmetic, relational, logical ) Display Facilities Flow Control Using of M-File Writing User

More information

USER GUIDE. PowerKB for Parature

USER GUIDE. PowerKB for Parature USER GUIDE PowerKB for Parature Contents Overview Using PowerKB for Parature Filters Search Bar Article Results Parature Article Copy Link Overview PowerKB for Parature is an integration between CRM and

More information

ECON 502 INTRODUCTION TO MATLAB Nov 9, 2007 TA: Murat Koyuncu

ECON 502 INTRODUCTION TO MATLAB Nov 9, 2007 TA: Murat Koyuncu ECON 502 INTRODUCTION TO MATLAB Nov 9, 2007 TA: Murat Koyuncu 0. What is MATLAB? 1 MATLAB stands for matrix laboratory and is one of the most popular software for numerical computation. MATLAB s basic

More information

Lecture 1. Course Overview Types & Expressions

Lecture 1. Course Overview Types & Expressions Lecture 1 Course Overview Types & Expressions CS 1110 Spring 2012: Walker White Outcomes: Basics of (Java) procedural programming Usage of assignments, conditionals, and loops. Ability to write recursive

More information

Introduction to Matlab. By: Dr. Maher O. EL-Ghossain

Introduction to Matlab. By: Dr. Maher O. EL-Ghossain Introduction to Matlab By: Dr. Maher O. EL-Ghossain Outline: q What is Matlab? Matlab Screen Variables, array, matrix, indexing Operators (Arithmetic, relational, logical ) Display Facilities Flow Control

More information

6.001 Notes: Section 15.1

6.001 Notes: Section 15.1 6.001 Notes: Section 15.1 Slide 15.1.1 Our goal over the next few lectures is to build an interpreter, which in a very basic sense is the ultimate in programming, since doing so will allow us to define

More information

MATH (CRN 13695) Lab 1: Basics for Linear Algebra and Matlab

MATH (CRN 13695) Lab 1: Basics for Linear Algebra and Matlab MATH 495.3 (CRN 13695) Lab 1: Basics for Linear Algebra and Matlab Below is a screen similar to what you should see when you open Matlab. The command window is the large box to the right containing the

More information

McTutorial: A MATLAB Tutorial

McTutorial: 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 information

Scheme: Expressions & Procedures

Scheme: Expressions & Procedures Scheme: Expressions & Procedures CS F331 Programming Languages CSCE A331 Programming Language Concepts Lecture Slides Friday, March 31, 2017 Glenn G. Chappell Department of Computer Science University

More information

ECE Lesson Plan - Class 1 Fall, 2001

ECE Lesson Plan - Class 1 Fall, 2001 ECE 201 - Lesson Plan - Class 1 Fall, 2001 Software Development Philosophy Matrix-based numeric computation - MATrix LABoratory High-level programming language - Programming data type specification not

More information

Unix Computer To open MATLAB on a Unix computer, click on K-Menu >> Caedm Local Apps >> MATLAB.

Unix Computer To open MATLAB on a Unix computer, click on K-Menu >> Caedm Local Apps >> MATLAB. MATLAB Introduction This guide is intended to help you start, set up and understand the formatting of MATLAB before beginning to code. For a detailed guide to programming in MATLAB, read the MATLAB Tutorial

More information

7 Control Structures, Logical Statements

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 information

CSCI 3155: Homework Assignment 3

CSCI 3155: Homework Assignment 3 CSCI 3155: Homework Assignment 3 Spring 2012: Due Monday, February 27, 2012 Like last time, find a partner. You will work on this assignment in pairs. However, note that each student needs to submit a

More information

Project Data: Manipulating Bits

Project Data: Manipulating Bits CSCI0330 Intro Computer Systems Doeppner Project Data: Manipulating Bits Due: September 26, 2018 at 11:59pm 1 Introduction 1 2 Assignment 1 2.1 Collaboration 3 2.2 TA Hours 3 3 The Puzzles 3 3.1 Bit Manipulations

More information

MATLAB TUTORIAL WORKSHEET

MATLAB TUTORIAL WORKSHEET MATLAB TUTORIAL WORKSHEET What is MATLAB? Software package used for computation High-level programming language with easy to use interactive environment Access MATLAB at Tufts here: https://it.tufts.edu/sw-matlabstudent

More information

Desktop Command window

Desktop Command window Chapter 1 Matlab Overview EGR1302 Desktop Command window Current Directory window Tb Tabs to toggle between Current Directory & Workspace Windows Command History window 1 Desktop Default appearance Command

More information

Deadline. Purpose. How to submit. Important notes. CS Homework 9. CS Homework 9 p :59 pm on Friday, April 7, 2017

Deadline. Purpose. How to submit. Important notes. CS Homework 9. CS Homework 9 p :59 pm on Friday, April 7, 2017 CS 111 - Homework 9 p. 1 Deadline 11:59 pm on Friday, April 7, 2017 Purpose CS 111 - Homework 9 To give you an excuse to look at some newly-posted C++ templates that you might find to be useful, and to

More information

Introduction and MATLAB Basics

Introduction and MATLAB Basics Introduction and MATLAB Basics Lecture Computer Room MATLAB MATLAB: Matrix Laboratory, designed for matrix manipulation Pro: Con: Syntax similar to C/C++/Java Automated memory management Dynamic data types

More information

Programming in C++ PART 2

Programming in C++ PART 2 Lecture 07-2 Programming in C++ PART 2 By Assistant Professor Dr. Ali Kattan 1 The while Loop and do..while loop In the previous lecture we studied the for Loop in C++. In this lecture we will cover iteration

More information

MAT 275 Laboratory 2 Matrix Computations and Programming in MATLAB

MAT 275 Laboratory 2 Matrix Computations and Programming in MATLAB MATLAB sessions: Laboratory MAT 75 Laboratory Matrix Computations and Programming in MATLAB In this laboratory session we will learn how to. Create and manipulate matrices and vectors.. Write simple programs

More information

Armstrong State University Engineering Studies MATLAB Marina 2D Arrays and Matrices Primer

Armstrong State University Engineering Studies MATLAB Marina 2D Arrays and Matrices Primer Armstrong State University Engineering Studies MATLAB Marina 2D Arrays and Matrices Primer Prerequisites The 2D Arrays and Matrices Primer assumes knowledge of the MATLAB IDE, MATLAB help, arithmetic operations,

More information

MATH 2221A Mathematics Laboratory II

MATH 2221A Mathematics Laboratory II MATH 2221A Mathematics Laboratory II Lab Assignment 1 Name: Class: Student ID.: In this assignment, you are asked to run MATLAB demos to see MATLAB at work. The color version of this assignment can be

More information

Transform data - Compute Variables

Transform data - Compute Variables Transform data - Compute Variables Contents TRANSFORM DATA - COMPUTE VARIABLES... 1 Recode Variables... 3 Transform data - Compute Variables With MAXQDA Stats you can perform calculations on a selected

More information

MAT 343 Laboratory 1 Matrix and Vector Computations in MATLAB

MAT 343 Laboratory 1 Matrix and Vector Computations in MATLAB MAT 343 Laboratory 1 Matrix and Vector Computations in MATLAB MATLAB is a computer software commonly used in both education and industry to solve a wide range of problems. This Laboratory provides a brief

More information

Introduction to MATLAB for Engineers, Third Edition

Introduction to MATLAB for Engineers, Third Edition PowerPoint to accompany Introduction to MATLAB for Engineers, Third Edition William J. Palm III Chapter 2 Numeric, Cell, and Structure Arrays Copyright 2010. The McGraw-Hill Companies, Inc. This work is

More information

MATLAB INTRODUCTION. Matlab can be used interactively as a super hand calculator, or, more powerfully, run using scripts (i.e., programs).

MATLAB INTRODUCTION. Matlab can be used interactively as a super hand calculator, or, more powerfully, run using scripts (i.e., programs). L A B 6 M A T L A B MATLAB INTRODUCTION Matlab is a commercial product that is used widely by students and faculty and researchers at UTEP. It provides a "high-level" programming environment for computing

More information

Vector: A series of scalars contained in a column or row. Dimensions: How many rows and columns a vector or matrix has.

Vector: A series of scalars contained in a column or row. Dimensions: How many rows and columns a vector or matrix has. ASSIGNMENT 0 Introduction to Linear Algebra (Basics of vectors and matrices) Due 3:30 PM, Tuesday, October 10 th. Assignments should be submitted via e-mail to: matlabfun.ucsd@gmail.com You can also submit

More information

Matlab Tutorial 1: Working with variables, arrays, and plotting

Matlab Tutorial 1: Working with variables, arrays, and plotting Matlab Tutorial 1: Working with variables, arrays, and plotting Setting up Matlab First of all, let's make sure we all have the same layout of the different windows in Matlab. Go to Home Layout Default.

More information

Ascii Art. CS 1301 Individual Homework 7 Ascii Art Due: Monday April 4 th, before 11:55pm Out of 100 points

Ascii Art. CS 1301 Individual Homework 7 Ascii Art Due: Monday April 4 th, before 11:55pm Out of 100 points CS 1301 Individual Homework 7 Ascii Art Due: Monday April 4 th, before 11:55pm Out of 100 points Files to submit: 1. HW7.py THIS IS AN INDIVIDUAL ASSIGNMENT! You should work individually on this assignment.

More information

MAT 275 Laboratory 2 Matrix Computations and Programming in MATLAB

MAT 275 Laboratory 2 Matrix Computations and Programming in MATLAB MATLAB sessions: Laboratory MAT 75 Laboratory Matrix Computations and Programming in MATLAB In this laboratory session we will learn how to. Create and manipulate matrices and vectors.. Write simple programs

More information

Computer and Programming: Lab 1

Computer and Programming: Lab 1 01204111 Computer and Programming: Lab 1 Name ID Section Goals To get familiar with Wing IDE and learn common mistakes with programming in Python To practice using Python interactively through Python Shell

More information

6.S189 Homework 1. What to turn in. Exercise 1.1 Installing Python. Exercise 1.2 Hello, world!

6.S189 Homework 1. What to turn in. Exercise 1.1 Installing Python. Exercise 1.2 Hello, world! 6.S189 Homework 1 http://web.mit.edu/6.189/www/materials.html What to turn in Do the warm-up problems for Days 1 & 2 on the online tutor. Complete the problems below on your computer and get a checkoff

More information

CS/NEUR125 Brains, Minds, and Machines. Due: Wednesday, March 8

CS/NEUR125 Brains, Minds, and Machines. Due: Wednesday, March 8 CS/NEUR125 Brains, Minds, and Machines Lab 6: Inferring Location from Hippocampal Place Cells Due: Wednesday, March 8 This lab explores how place cells in the hippocampus encode the location of an animal

More information

Introduction to MATLAB. CS534 Fall 2016

Introduction to MATLAB. CS534 Fall 2016 Introduction to MATLAB CS534 Fall 2016 What you'll be learning today MATLAB basics (debugging, IDE) Operators Matrix indexing Image I/O Image display, plotting A lot of demos... Matrices What is a matrix?

More information

EE168 Lab/Homework #1 Introduction to Digital Image Processing Handout #3

EE168 Lab/Homework #1 Introduction to Digital Image Processing Handout #3 EE168 Lab/Homework #1 Introduction to Digital Image Processing Handout #3 We will be combining laboratory exercises with homework problems in the lab sessions for this course. In the scheduled lab times,

More information