Rationale Objective(s) Exploration - University of Arkansas

4 downloads 34 Views 77KB Size Report
Page 1 of 6. LESSON TITLE: OCTAVE OVERVIEW. 11/7/11. Copyright © 2008, 2009, 2011 by Dale R. Thompson {[email protected]}. Rationale.
Page 1 of 6

LESSON TITLE: OCTAVE OVERVIEW 11/7/11 Copyright © 2008, 2009, 2011 by Dale R. Thompson {[email protected]}

Rationale Why is this lesson important? Why does the student need this lesson? How does this lesson fit in the larger module? GNU Octave is a high-level language for performing numerical calculations. In addition, Octave can plot the results using simple commands. The student needs this lesson to know how to use such a tool for applying the fast Fourier transform (FFT) and plotting the results. This will enable the student to focus more on analysis of signals instead of the details of FFT.

Objective(s) What will the student know, be able to do, and value at the end of this lesson? This is smaller amounts of information than the module objectives. The student will be able to evaluate algebraic functions and plot the functions using Octave.

Exploration Explicit concepts related to the Module goal are explored. It is at this point that the student will be provided basic information about the topic and the chance to explore some basic concepts about the topic. This is where the instructor imparts information. •

Octave performs numerical calculations and can graph the results



Its strength is doing matrix computations



Octave is not a symbolic solver



Octave is similar to MatLab and most commands are compatible



Unlike the language C, Octave is interactive



Example calculations

octave octave:1> 1+2 ans = 3 octave:2> 1/2 ans = 0.50000 octave:3> 3^2 ans = 9 octave:4> pi ans = 3.1416 octave:5> x = 4/3+1-2 x = 0.33333 octave:6>% This is a comment

% who displays the variables % clear deletes all variables % save FILENAME – Saves the workspace to FILENAME.mat % load FILENAME octave:7>a = 1; octave:8>b = 2; octave:9>c = a + b c = 3 octave:10> • Vectors and matrices octave:1>v1 = [1 2 3] v1 = 1

2

3

octave:2>v2 = [4, 5, 6] v2 = 4

5

6

octave:3>v3 = [7; 8; 9] v3 = 7 8 9 octave:4>m1 = [1,2,3; 4,5,6; 7,8,9] m1 = 1 4 7 •

2 5 8

3 6 9

Colon notation

octave:1>L1=4:8 L1 = 4

5

6

7

8

octave:2>L2=4:2:8 L2 = 4 •

6

8

Extracting elements from a vector

Page 3 of 6 octave:1>v4 = [3:2:8 11 15] v4 = 3

5

7

11

15

octave:2>v4(4) ans = 11 •

Plots

angles = [0:pi/4:2*pi]; y = cos(angles); plot(angles,y) •

Functions and commands can be saved in script files named *.m

edit % opens editor %Type FILENAME to run script

Reflection Several questions are posed to the student to answer and then often discuss as a class. This is an attempt to determine whether the student "gets" the basic concepts delivered above. If they do get it, move on to engagement. If they do not get it, go back to exploration above. It could be as simple as asking a few probing questions or as complex as asking the student to write a paper. •

How do you suppress the output in Octave?



Why did the command pi display 3.1416?



How do you create a column vector?



How do you create a row vector?



How do you extract multiple adjacent elements from a vector?



What is the command for plotting?



How do you run a script file FILENAME.m?

Engagement Concepts learned in the Exploration are further developed by conducting experiments, designing and building solutions, and solving problems. This is an attempt to cause the student to apply the new knowledge. By applying the new knowledge, the student is much more likely to retain this information. This engagement could be accomplished through a debate, an experiment, a problem solving activity, or anything else that would cause the student to demonstrate understanding and competence.

1.

In Octave, type the following. What happens?

a = [1, 2, 3, 4]; b = [5, 6, 7, 8]; a*b

2. Now, type the following. What happens? a.*b 3. Now, type the following. What happens? c = [a; b] 4. What command extracts the element from the second row and third column?

Expansion Provide opportunities for students to expand the concepts to more general or global situations including connection to the Module goal. Expand back to the big ideas of the module and prepare for the next lesson. •

What are the advantages of using a high-level language like Octave?



Is it easy to create plots in Octave?



Given a set of complex numerical computations, would you rather use Octave or a language like C or Java?

Lesson Assessment Assess student understanding of the lesson content. This does not have to be a full-blown examination. It could be a graded homework assignment, a quiz, a performance examination, a graded problem solving activity, or something similar. •

Octave homework assignment

Equipment •

PC running Windows or Linux

Software •

GNU Octave (license under GPL), which is mostly compatible with Matlab o

Available: http://www.gnu.org/software/octave

o

Manual: http://www.gnu.org/software/octave/doc/interpreter/

o

Packages and function reference: http://octave.sourceforge.net/

Page 5 of 6

References •

John W. Eaton, GNU Octave Manual, Network Theory Limited, 2002. ISBN: 0-9541617-2-6. Available: http://www.gnu.org/software/octave

Copyright Notice This material is Copyright © 2008, 2009, 2011 by Dale R. Thompson. It may be freely redistributed in its entirety provided that this copyright notice is not removed. It may not be sold for profit or incorporated in commercial documents without the written permission of the copyright holder.

Acknowledgment These materials were developed through a grant from the National Science Foundation at the University of Arkansas. Any opinions, findings, and recommendations or conclusions expressed in these materials are those of the author(s) and do not necessarily reflect those of the National Science Foundation or the University of Arkansas.

Liability Release The curriculum activities and lessons have been designed to be safe and engaging learning experiences and have been field-tested with university students. However, due to the numerous variables that exist, the author(s) does not assume any liability for the use of this product. These curriculum activities and lessons are provided as is without any express or implied warranty. The user is responsible and liable for following all stated and generally accepted safety guidelines and practices.