MATH 2221A Mathematics Laboratory II

Similar documents
MATH 2221 A Mathematics Laboratory II

MATH 2221A Mathematics Laboratory II

LAB 2: Linear Equations and Matrix Algebra. Preliminaries

Introduction to Engineering gii

Outline. CSE 1570 Interacting with MATLAB. Outline. Starting MATLAB. MATLAB Windows. MATLAB Desktop Window. Instructor: Aijun An.

Outline. CSE 1570 Interacting with MATLAB. Starting MATLAB. Outline. MATLAB Windows. MATLAB Desktop Window. Instructor: Aijun An.

Outline. CSE 1570 Interacting with MATLAB. Starting MATLAB. Outline (Cont d) MATLAB Windows. MATLAB Desktop Window. Instructor: Aijun An

1 Introduction to Matlab

MATLAB Demo. Preliminaries and Getting Started with Matlab

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

MAT 343 Laboratory 1 Matrix and Vector Computations in MATLAB

Math 250A (Fall 2009) - Lab I: Estimate Integrals Numerically with Matlab. Due Date: Monday, September 21, INSTRUCTIONS

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

1 Overview of the standard Matlab syntax

EE 350. Continuous-Time Linear Systems. Recitation 1. 1

Introduction to MATLAB

MAT 343 Laboratory 1 Matrix and Vector Computations in MATLAB

Matlab Tutorial: Basics

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

Computer Programming ECIV 2303 Chapter 1 Starting with MATLAB Instructor: Dr. Talal Skaik Islamic University of Gaza Faculty of Engineering

CVEN 302. Computer Applications in Engineering and Construction. Dr. Tony Cahill Environmental and Water Resources Division

WHAT IS MATLAB?... 1 STARTING MATLAB & USING THE COMMAND LINE... 1 BASIC ARITHMETIC OPERATIONS... 5 ORDER OF OPERATIONS... 7

2.0 MATLAB Fundamentals

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

1-6 Order of Operations

Introduction to Octave/Matlab. Deployment of Telecommunication Infrastructures

MatLab Just a beginning

Introduction to MatLab. Introduction to MatLab K. Craig 1

A/D Converter. Sampling. Figure 1.1: Block Diagram of a DSP System

AMS 27L LAB #1 Winter 2009

Why use MATLAB? Mathematcal computations. Used a lot for problem solving. Statistical Analysis (e.g., mean, min) Visualisation (1D-3D)

EE3TP4: Signals and Systems Lab 1: Introduction to Matlab Tim Davidson Ext Objective. Report. Introduction to Matlab

CMPE 180A Data Structures and Algorithms in C++ Spring 2018

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

What is MATLAB? What is MATLAB? Programming Environment MATLAB PROGRAMMING. Stands for MATrix LABoratory. A programming environment

LAB 1 General MATLAB Information 1

GUIDELINES FOR COMPLETING THE ASSIGNMENT

Fall 2017: Numerical Methods I Assignment 1 (due Sep. 21, 2017)

George Mason University ECE 201: Introduction to Signal Analysis Spring 2017

Math 2250 MATLAB TUTORIAL Fall 2005

Week 1: Introduction to R, part 1

APPM 2360 Lab #2: Facial Recognition

Experiment 1: Introduction to MATLAB I. Introduction. 1.1 Objectives and Expectations: 1.2 What is MATLAB?

Chapter 1: Number and Operations

Chapter 2 (Part 2) MATLAB Basics. dr.dcd.h CS 101 /SJC 5th Edition 1

Lab 1 Intro to MATLAB and FreeMat

PHYS 210: Introduction to Computational Physics MATLAB Exercises 2

MATH 137 : Calculus 1 for Honours Mathematics. Online Assignment #5. Limits and Continuity of Functions

Question. Insight Through

Image Manipulation in MATLAB Due Monday, July 17 at 5:00 PM

The Very Basics of the R Interpreter

MAT 4199C/5107 Second Homework Assignment Due 13 Feb by 1:00pm

Creates 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.

Intermediate Algebra. Gregg Waterman Oregon Institute of Technology

AMATH 352: MATLAB Tutorial written by Peter Blossey Department of Applied Mathematics University of Washington Seattle, WA

You must pass the final exam to pass the course.

PART 1 PROGRAMMING WITH MATHLAB

Introduction to MATLAB Practical 1

GEORGIA INSTITUTE OF TECHNOLOGY. SCHOOL of ELECTRICAL and COMPUTER ENGINEERING. ECE 2026 Summer 2018 Lab #0: Introduction to MATLAB

Basic stuff -- assignments, arithmetic and functions

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

Department of Computer Science

Computer Programming in MATLAB

An Introduction to MATLAB

Python Programming Exercises 1

McTutorial: A MATLAB Tutorial

Introduction to MATLAB

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

Matlab = Matrix Laboratory. It is designed to be great at handling matrices.

A Brief Introduction to MATLAB

ENGR 1181c Midterm Exam 2: Study Guide and Practice Problems

Excel Basics Fall 2016

Course Layout. Go to follow instr. Accessible within campus (only for the first download)

MS213: Numerical Methods Computing Assignments with Matlab

MAT 182: Calculus II Test on Chapter 6: Applications of Integration Take-Home Portion Points as Assigned for Each Exercise 40 Points Total.

MAT 343 Laboratory 2 Solving systems in MATLAB and simple programming

Grace days can not be used for this assignment

Math 3820 Project. 1 Typeset or handwritten? Guidelines

Introduction to MATLAB

MAT 275 Laboratory 1 Introduction to MATLAB

1. Register an account on: using your Oxford address

EE 301 Lab 1 Introduction to MATLAB

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

If a b or a c, then a bc If a b and b c, then a c Every positive integer n > 1 can be written uniquely as n = p 1 k1 p 2 k2 p 3 k3 p 4 k4 p s

Fall 2015 Math 337. Basic MatLab

Catholic Central High School

Signals and Systems Profs. Byron Yu and Pulkit Grover Fall Homework 1

Watkins Mill High School. Algebra 2. Math Challenge

AN INTRODUCTION TO MATLAB

Eric W. Hansen. The basic data type is a matrix This is the basic paradigm for computation with MATLAB, and the key to its power. Here s an example:

Introduction to Matlab. Summer School CEA-EDF-INRIA 2011 of Numerical Analysis

Introduction to Matlab

CS 135 Lab Assignments Week 1

ELEMENTARY MATLAB PROGRAMMING

Formatting for TLM - Part I

Working with Algebraic Expressions

STAT/MATH 395 A - PROBABILITY II UW Winter Quarter Matlab Tutorial

SF1901 Probability Theory and Statistics: Autumn 2016 Lab 0 for TCOMK

Introduction to Matlab

CSE/NEUBEH 528 Homework 0: Introduction to Matlab

Transcription:

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 found in your own H:\ drive. Instructions 1. Your first task is to set up your own password after logging in. 2. Start MATLAB, until you see a window with the MATLAB prompt». This window is called the Command Window. 3. After you started have MATLAB, you will automatically be in the directory H:\. Please enter diary on after the MATLAB prompt» only once to record all your work in H:\diary. No marks will be given if no diary is found. 4. Enter demo after the prompt». You will see a new window with many things to play with. This is the Demo Window. 5. In the Demo Window, try to locate figures or problems similar to those in the exercises below. Then locate the commands that generate these figures or problems. Try them in the Command Window. Just enter (or cut and paste) the commands after» to see what happens. 6. You should write your results on the lab sheet provided, and save the figures in the H: drive, in your personal drive. 7. Please read and sign the following declaration before handing in your assignment. Otherwise, no marks will be given. I declare that the assignment here submitted is original except for source material explicitly acknowledged. I also acknowledge that I am aware of University policy and regulations on honesty in academic work, and of the disciplinary guidelines and procedures applicable to breaches of such policy and regulations, as contained in the website http://www.cuhk.edu.hk/policy/academichonesty/ Signature Date MATH 2221 Mathematics Laboratory II 1

1 (30 marks) 6 (Optional) 2 (30 marks) 3 (25 marks) 4 (15 marks) 5 (Optional) Please read the following carefully: General Guidelines for Lab Assignment Submission. Please sign and date the statement of Academic Honesty. Please go to the class and lab indicated by your registered course code via the CUSIS system. If you go to a different lab than the one you are registered for, you will not receive credit for the assignment even if you completed it. Write your COMPLETE name and student ID number legibly on the cover sheet (otherwise we will not take any responsibility for your lab). Please write your answers using a black or blue pen, NOT any other color or a pencil. Write your solutions on a double-sided printout of this pdf file. Try to fit your answers inside the available space. The use of computers/cellular phones/graphing calculators/ipads will NOT be permitted during tests and lab assignments. Please do not use our lab computer to recharge your cellar phone battery. No photo taking is allowed in the lab. In order to make it fair for all students, during the labs and tests, if you touch/press any icons on your cellular phone, our TA will check your phone to determine whether or not you are exchanging messages with another student. If you are found cheating (in the tests or in the lab or on homework assignments), you will automatically get an F grade in this course and your act will be reported to the Department for necessary disciplinary actions. Exercises 1. (Arithmetic Operations, 30 marks) What You Will Learn Arithmetic Operations: You can use MATLAB as a calculator in the command window at the command line. Variables: MATLAB allows you to store case-sensitive variables. MATH 2221 Mathematics Laboratory II 2

Question The mathematics calculations to be performed are typed directly into the Command Window, using the symbols = +,,, /, and for equals, addition, subtraction, multiplication, division, and exponentiation, respectively. The distance traveled by a ball falling in the air is given by the equation x = x 0 + v 0 t + 1 2 at2. Use MATLAB to calculate the position of the ball at time t = 5 s if x 0 = 10 m, v 0 = 12 m/s, and a = 9.81 m/sec 2. Write down all the MATLAB command lines. >> x0 = 10; v0 = 12; a = -9.81; t = 5; x = x0 + v0*t + 0.5*a*t^2 x = -52.6250 2. (Basic Matrix Operations, 30 marks) What You Will Learn Linear Algebra: Examine the properties of matrices. Question You can do either >> A = [ 1 2; 5 3]; B = [ -2 2; 0 1]; C = [4; 2]; D = 6; or >> A = [ 2, 1; 3, 4]; B = [ -1, 2; 0, 1]; C = [2; 4]; D = 2; and do not have to do both. What is the result of each of the following expressions (try to read the message of MATLAB and find out the reason if any error occurs)? (a) (5marks) A+B (b) (5marks) A.*B (c) (5marks) A*B (d) (5marks) A*C (e) (optional) A+C (f) (optional) A+D (g) (optional) A.*D (h) (optional) A*D Can you tell the difference between the MATLAB.* and * commands (10 marks)? Write down all the MATLAB command lines. MATH 2221 Mathematics Laboratory II 3

>> A = [ 1 2; 5 3]; B = [ -2 2; 0 1]; C = [4; 2]; D = 6; >> A+B >> A.*B >> A*B -1 4 5 4-2 4 0 3-2 4-10 13 >> A*C 8 26 >> A+C Error using + Matrix dimensions must agree. >> A+D >> A.*D >> A*D 7 8 11 9 6 12 30 18 MATH 2221 Mathematics Laboratory II 4

6 12 30 18 The MATLAB command.* computes element-wise multiplication, and the * is for standard matrix multiplication. MATH 2221 Mathematics Laboratory II 5

3. (Exponents and Logarithms, 25 marks) What You Will learn Exponents and Logarithms: Type Question >> help exp >> help log >> help log10 >> help sqrt The following problems can be solved by writing commands in the Command Window, or by writing a program in a script file and then executing the file. (a) 3 5 3 2 + 6/2 + elog 10 (8) ; (b) 12.62 + 5.5 3 3.8 3/2 + 65 3 + 14 + e 5 ln(64). Write down all the MATLAB command lines. >> (3 * 5 )/( 3^2 + 6/2) + exp(log10(8)) 3.7172 >> (12.6^2 + 5.5^3)/(3.8^(3/2)) + 65/(sqrt(3) + 14) + exp(5)*log(64) 665.2570 4. (Images, 15 marks) MATLAB can read a greyscale or color image from graphic files using the command imread(fillename). For example, the command A=imread( antennaegalaxy.jpg ) reads the image from the file named "antennaegalaxy.jpg" and stores it in A. MATH 2221 Mathematics Laboratory II 6

Figure 1: Antennae galaxy. Source http://science.nationalgeographic.com Try to use the file "antennaegalaxy.jpg" which can be found in the H: drive and do the following (5 marks) Read the image from the file (put the file in MATLAB current folder first, if it is not). (5 marks) Display the image in MATLAB. (5 marks) Convert the image to grayscale and then show it again. Hint: MATLAB demo provides many useful MATLAB Examples. Type demo in the command line and try to find something you need. Write down all the MATLAB command lines. A = imread( antennaegalaxy.jpg ); imshow(a); B = rgb2gray(a); imshow(b); MATH 2221 Mathematics Laboratory II 7

5. (MATLAB Built-in Functions, optional) What You Will Learn Built-in functions: the MATLAB ones and zeros commands. Help for functions in the Command Window: Type Question >> help ones >> help zeros >> help linspace Use the MATLAB ones and linspace commands and basic matrix operations to create the following matrix: 1 2 3 4 5 6 2 3 4 5 6 7 H = 3 4 5 6 7 8. 4 5 6 7 8 9 5 6 7 8 9 10 >> H = ones(5,1)*linspace(1,6,6) + linspace(0,4,5) *ones(1,6) H = 1 2 3 4 5 6 2 3 4 5 6 7 3 4 5 6 7 8 4 5 6 7 8 9 5 6 7 8 9 10 6. (Operator Precedence, optional) Question MATLAB executes the calculations according to the order of precedence displayed below. This order is the same as used in most calculators. First Second Third Fourth Parentheses. For nested parentheses, the innermost are are executed first. Exponentiation. Multiplication, Division (equal precedence). Addition and Subtraction Variables a, b, c, and d have been initialized to the following values: a = 3; b = 2; c = 5; d = 3. MATH 2221 Mathematics Laboratory II 8

Evaluate the following MATLAB assignment statements: (a) output = a b + c d (b) output = a (b + c) d (c) output = (a b) + (c d) (d) output = a b c (e) output = a (b c) >> a = 3; b = 2; c = 5; d = 3; >> a*b+c*d 21 >> a*(b+c)*d 63 >> (a*b)+(c*d) 21 >> a^b^c 59049 >> a^(b^c) 1.8530e+15 MATH 2221 Mathematics Laboratory II 9