This module aims to introduce Precalculus high school students to the basic capabilities of Matlab by using functions. Matlab will be used in

Similar documents
Mechanical Engineering Department Second Year (2015)

12 whereas if I terminate the expression with a semicolon, the printed output is suppressed.

Getting Started. Chapter 1. How to Get Matlab. 1.1 Before We Begin Matlab to Accompany Lay s Linear Algebra Text

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

Logical Subscripting: This kind of subscripting can be done in one step by specifying the logical operation as the subscripting expression.

PART 1 PROGRAMMING WITH MATHLAB

PROGRAMMING WITH MATLAB WEEK 6

MATLAB Introduction to MATLAB Programming

INTRODUCTION TO MATLAB PLOTTING WITH MATLAB

Introduction to Matlab to Accompany Linear Algebra. Douglas Hundley Department of Mathematics and Statistics Whitman College

INC151 Electrical Engineering Software Practice. MATLAB Graphics. Dr.Wanchak Lenwari :Control System and Instrumentation Engineering, KMUTT 1

STAT 391 Handout 1 Making Plots with Matlab Mar 26, 2006

fplot Syntax Description Examples Plot Symbolic Expression Plot symbolic expression or function fplot(f) fplot(f,[xmin xmax])

Computer Programming in MATLAB

Dr Richard Greenaway

Introduction to MATLAB LAB 1

1 Introduction to Matlab

Overview. Lecture 13: Graphics and Visualisation. Graphics & Visualisation 2D plotting. Graphics and visualisation of data in Matlab

Graphics Example a final product:

DSP Laboratory (EELE 4110) Lab#1 Introduction to Matlab

Department of Chemical Engineering ChE-101: Approaches to Chemical Engineering Problem Solving MATLAB Tutorial Vb

Basic Graphs. Dmitry Adamskiy 16 November 2011

Appendix A. Introduction to MATLAB. A.1 What Is MATLAB?

What is Matlab? A software environment for interactive numerical computations

Graphics and plotting techniques

GUI Alternatives. Syntax. Description. MATLAB Function Reference plot. 2-D line plot

An Introduction to MATLAB II

Introduction to Matlab

GK-12 Lesson Plan. Discrete Cosine Transform, compression, jpg, transform. Five minutes researching the DCT.

QUICK INTRODUCTION TO MATLAB PART I

1. Register an account on: using your Oxford address

PyPlot. The plotting library must be imported, and we will assume in these examples an import statement similar to those for numpy and math as

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.

PC-MATLAB PRIMER. This is intended as a guided tour through PCMATLAB. Type as you go and watch what happens.

Classes 7-8 (4 hours). Graphics in Matlab.

Dr. Iyad Jafar. Adapted from the publisher slides

Prof. Manoochehr Shirzaei. RaTlab.asu.edu

MATLAB Guide to Fibonacci Numbers

What is MATLAB? It is a high-level programming language. for numerical computations for symbolic computations for scientific visualizations

Introduction to MATLAB: Graphics

The Department of Engineering Science The University of Auckland Welcome to ENGGEN 131 Engineering Computation and Software Development

AMS 27L LAB #2 Winter 2009

PowerPoints organized by Dr. Michael R. Gustafson II, Duke University

Lab #1 Revision to MATLAB

Introduction to Matlab

Introduction to Scientific Programming in MATLAB

PyPlot. The plotting library must be imported, and we will assume in these examples an import statement similar to those for numpy and math as

A General Introduction to Matlab

Matlab Tutorial and Exercises for COMP61021

Introduction to Matlab

Introduction to MATLAB

Basic plotting commands Types of plots Customizing plots graphically Specifying color Customizing plots programmatically Exporting figures

You can change the line style by adding some information in the plot command within single quotation marks.

MATLAB SUMMARY FOR MATH2070/2970

Introduction to Matlab

MATLAB Fundamentals. Berlin Chen Department of Computer Science & Information Engineering National Taiwan Normal University

Chapter 2. MATLAB Fundamentals

2D LINE PLOTS... 1 The plot() Command... 1 Labeling and Annotating Figures... 5 The subplot() Command... 7 The polarplot() Command...

MAT 275 Laboratory 1 Introduction to MATLAB

Basic Beginners Introduction to plotting in Python

Chapter 3: Introduction to MATLAB Programming (4 th ed.)

Homework 1 Description CmpE 362 Spring Instructor : Fatih Alagoz Teaching Assistant : Yekta Said Can Due: 3 March, 23:59, sharp

Introduction to Octave/Matlab. Deployment of Telecommunication Infrastructures

EGR 102 Introduction to Engineering Modeling. Lab 05B Plotting

Additional Plot Types and Plot Formatting

Can be put into the matrix form of Ax=b in this way:

UNIVERSITI TEKNIKAL MALAYSIA MELAKA FAKULTI KEJURUTERAAN ELEKTRONIK DAN KEJURUTERAAN KOMPUTER

MATLAB Tutorial III Variables, Files, Advanced Plotting

Starting a New Matlab m.file. Matlab m.files. Matlab m.file Editor/Debugger. The clear all Command. Our Program So Far

Getting started with MATLAB

Introduction to MatLab. Introduction to MatLab K. Craig 1

Introduction to MATLAB

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

Introduction To MATLAB Introduction to Programming GENG 200

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

Purpose of the lecture MATLAB MATLAB

MATLAB Introduction. Contents. Introduction to Matlab. Published on Advanced Lab (

Objectives. 1 Running, and Interface Layout. 2 Toolboxes, Documentation and Tutorials. 3 Basic Calculations. PS 12a Laboratory 1 Spring 2014

Part #6. A0B17MTB Matlab. Miloslav Čapek Filip Kozák, Viktor Adler, Pavel Valtr

Introduction to MATLAB

Matlab Tutorial for COMP24111 (includes exercise 1)

Due date for the report is 23 May 2007

Programming 1. Script files. help cd Example:

Introduction to MATLAB

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

MATLAB Tutorial. Primary Author: Shoumik Chatterjee Secondary Author: Dr. Chuan Li

Approximate First and Second Derivatives

MATLAB Tutorial EE351M DSP. Created: Thursday Jan 25, 2007 Rayyan Jaber. Modified by: Kitaek Bae. Outline

Introduction to MATLAB Programming. Chapter 3. Linguaggio Programmazione Matlab-Simulink (2017/2018)

LabVIEW MathScript Quick Reference

MATLAB Tutorial. 1. The MATLAB Windows. 2. The Command Windows. 3. Simple scalar or number operations

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

MATLAB Tutorial. Mohammad Motamed 1. August 28, generates a 3 3 matrix.

MATLAB Modul 3. Introduction

Introduction to MATLAB

ECE 202 LAB 3 ADVANCED MATLAB

Working with Charts Stratum.Viewer 6

Computing Fundamentals Plotting

Interactive Computing with Matlab. Gerald W. Recktenwald Department of Mechanical Engineering Portland State University

EE 1105 Pre-lab 3 MATLAB - the ins and outs

Transcription:

This module aims to introduce Precalculus high school students to the basic capabilities of Matlab by using functions. Matlab will be used in subsequent modules to help to teach research related concepts or to help emphasize classroom learning. This Introduction to Matlab package includes a lesson plan, a PowerPoint presentation, a worksheet and a reference sheet.

Science Lesson Plan Teacher: Period: Class: AP Precalc Date(s): Lesson # 1 Introduction to Matlab using Functions SETTING THE STAGE Essential Question How to visualize functions, their domain and range? Content Objective(s) (Student-friendly) Introduces basic Matlab commands for creating functions, defining variables and specifying their domain. Visualization through one-dimensional plots will also be introduced, to compare different functions. Connection to previous or future lessons Critical Thinking Questions Material in this lesson plan will serve as a background for future lessons which will be used to show Precalculus concepts in an alternate way and to demonstrate research related concepts. What is the importance of knowing what the graphical representation of a function looks like? What are some benefits of being able to manipulate the scale of a graph? Key Vocabulary Variables Functions Scale Domain Range Maxima Minima Linear Materials Needed/Safety ACTIVE INSTRUCTION Launch (Engage) Computers with Matlab software Matlab reference guide. Matlab code Display some 2-d or 3-d visualization from Matlab using an existing demo application. Ask students questions about what they see and how they think this was generated. Explain briefly what the simulation is about and give them a hands on activity where they can change some parameter of this application and see a difference. Students will also see a short vide titled Matlab is Cool The intention of showing the video is to convey other students excitement for a software tool like Matlab *This template is available in electronic form. 1

Teacher: Investigation (Explore) TIME FOR REFLECTION Summarization (Explain & Extend) Science Lesson Plan Following the launch, students will be introduced to some basic commands and will learn how create a basic linear function and its graph. F(x)=2x+3 They will later be asked to change the slope of the function the will be asked what changes they notices when the slope changes. Students will not be told that the coefficient in front of x is the slope. They will be asked to describe the graph in terms of decrease or increase and rate of change. We will discuss the importance of being able to find the domain and range of a function with an appropriate scale for graphing. If time permits students will be asked to compare the functions G(x) = 3x^2, x<1 F(x) = 3x^2, x>1 Discuss the use of simulation and how it is helpful to visualize the data. Explain thoroughly the plot that was generated. Explain what is to be presented next class. Ask the students to identify what was the most useful component in the computational exercises. Discuss why and how the students would use the software. Ask the students to note their observations in their journals. Assessment (Evaluate) Written notes in their journals will be reviewed. Homework *This template is available in electronic form. 2

Elaine Silvana Vejar NSF GK 12 Fellow Vibes and Waves in Action Center for Advanced Computation and Telecommunications University of Massachusetts Lowell a

Matlab Matlab is Cool!

Outline M files Matlab desktop Variables Arrays Plots

M files Save set of commands in a file Long code that requires more than a couple of commands Allows you to save code Extension that is used in matlab Examples Filename.m, anyname.m

How to create an m file Click on File in upper left hand side Click on new Click on blank m file Type code Save as

How to open/edit/close an m file Click on file Click on open Then choose the m file Make any changes needed to the file Click on save Then close the file by the x located in the upper right hand or File > Close

Matlab Desktop Command Window Workspace Command History

Variable Assignment >>a=4 Simple numerical assignment >>t = 10 4 Result of an operation >>p= pi Special assignment >>z = 3 + y Result of an operation with variables

Arrays MATLAB variables are arrays of numbers. An array consisting of one element is called a scalar. Scalar: a scalar is a single value (i.e. a number) >>b =2 Vector: a vector is an ordered series of numbers >>c=[0,2,4,6,8,10,12,14] >> d=0:2:14 What do you observe?

Helpful Commands >>save saves the file from the command window >>clear clears the workspace >>clc clears the command window >>load load the specified file from the command window

Plots Let s graph f(x)=2*x+3, x 1 It s almost like making a table, what values of x do we want? Anything less than or equal to zero, so are maximum x value is 1 >> x= 100:6:1 What does this do? >> fx=2*x+3 >>plot(x,fx) plots 2 d data with x axis with values of x and y axis with values of y

Change plot line color For example >>plot(x,fx, b ) will make the plot line color blue Color options g green r red c cyan m magenta k black

Multiple Functions in one Plot >>fx=2*x+3 >>fx1= 10*x+3 >>fx2=10*x+3 Now try: >>plot(x,fx, r,x,fx1, b,x,fx2, c ) How can you tell which line belong to the correct function?

Change Line Style For example >>plot(x,y, ) will make the line style solid Other line styles: dashed : dotted. dash dot

Change plot marker >>plot(x, y, d ) diagonal cross Other marker options + vertical cross * star d diamond

Plot types Bar graph >>bar(x,y) 6 4 2 0 Bar Category 1 Category 2Category 3 Category 4 Bar Stem graph >>stem(x,y)

Annotating Plots To make a label for the x axis >>xlabel( The label for x ) To make a label for the y axis >>ylabel( The label for y ) To make a title for the Plot >>title( Our First Plot )

Plotting data Type in the following code (excluding the comments denoted by %): xmin= 20; %assign starting value of x xmax=20; %assign end value of x dt=2; % assign increment x=xmin:dt:xmax; %define independent vector fx=2*x+5; %define the function gx=15*x+3; % define second function plot(x,fx,'r',x,gx,'b'); %plot first function with color of red. 'r' red and second function with blue grid on %shows grid lines xlabel('x= 20 to 20'); %set label for x axis ylabel( labeling the y axis'); %set label for y axis title( My first graph in Matlab'); %set title

Let s Compare Write your observations and sketch the functions in your notebooks G(x)=5x^2 x<1 P(x)=5x^3 x<1 And: G(x)=5x^2 x>1 P(x)=5x^3 x>1

Using Matlab to Plot Functions Name: Date: First identify the grandmother function, then plot and describe the transformation of the following functions: Grandmother Function Function 1 Function 2 2 3 2 4 1 2 2 5 10 5

M-Files New M-Files File New M-File (opens blank page) Open M-Files File Open Select a desired M-File Click Open Save M-Files New File Save As Select a folder where you want to save your new M- File Old File Save (Ctrl + S) Vectors Data Stored as Vectors and Matrices Row vector A = [1 2 3 4]; leave space between each number. This generates 1 x 4 row vector Column vector B = [1; 2; 3; 4]; add semicolon(;) between each number. This generates 4x1 column vector Example: 3 x 2 Matrix C = [ 1 2; 3 4; 5 6] = [ 1 2 3 4 5 6] Plot 2D plot plot(x,y) plots a graph of y = f(x) Label Note: first plot a graph than label it xlabel( x-axis ) labels x-axis, make sure open and close the parenthesis, and add single quotation mark at the beginning and at the end. x-axis ylabel( y-axis ) labels y-axis title( y vs. x ) to display a title at the top location of the graph legend( y = f(x) ); describes the figure Subplot Used to represents multiple graphs in single page subplot(2,3,4); Used to place plots on same page: subplot(r,c,i) i =1, 2,.r x c r=row c=column i=placement of graph Note: First use subplot command then repeat plot, xlabel, ylabel etc. for every subplots. subplot(2,3,1); plot(x1,y1); xlabel(. ). subplot(2,3,2); plot(x2,y2); xlabel(. ). subplot(2,3,3); plot(x3,y3); xlabel(. ). LineSpec Arguments for plot Line Style - Solid line (default) -- Dashed line : Dotted line -. Dash-dot line Marker + Plus sign o Circle * Asterisk. Point x Cross s Square d Diamond ^ Upward pointing triangle > Right pointing triangle < Left pointing triangle p Five-pointed star (pentagon) h Six-pointed star (hexagon) Color r Red g Green b Blue c Cyan m Magenta y Yellow k Black w White

Matlab Desktop M-Files Plot LineSpec Arguments for plot Current Directory Command Window Workspace Sample code %define a variable x as a 1X4 %vector that contains the numbers % 1 through 4 x = [1 2 3 4] % find the dimensions of the vector size(x) %find the length of the row vector length(x) Details Command History

Random Numbers normrnd syntax R= normrnd(mu,sigma,m,n) Description Generates random numbers from the normal distribution with mean parameter mu and standard deviation parameter sigma, where scalars m and n are the row and column dimensions of R Example R= normrnd([1 2 3 ;4 5 6],0.1,3.2) R= 0.9299 1.9361 2.9640 4.1246 5.0577 5.9864 2D plot hist state randn Description Generates a set of pseudorandom numbers from a standard normal distribution randint syntax out = randint(m,n,rg) Description