Programming Assignment Six. Semester Calendar. 1D Excel Worksheet Arrays. Review VBA Arrays from Excel. Programming Assignment Six May 2, 2017

Similar documents
Solutions to Programming Assignment Five Interpolation and Numerical Differentiation

Outline. Third Programming Project Two-Dimensional Arrays. Files You Can Download. Exercise 8 Linear Regression. General Regression

Review for Programming Exam and Final May 4-9, Ribbon with icons for commands Quick access toolbar (more at lecture end)

Introduction to Arrays. Midterm Comments. Midterm Results. Midterm Comments II. Function Basics (Problem 2) Introduction to Arrays April 11, 2017

Outline. Writing Functions and Subs. Review Immediate (1-line) Errors. Quiz Two on Thursday (2/23) Same Code Without Option Explicit

Midterms Save the Dates!

Outline. Midterm Review. Declaring Variables. Main Variable Data Types. Symbolic Constants. Arithmetic Operators. Midterm Review March 24, 2014

Programming in Fortran 90 : 2017/2018

Outline. CIS 110: Intro to Computer Programming. What Do Our Programs Look Like? The Scanner Object. CIS 110 (11fa) - University of Pennsylvania 1

Assembler. Building a Modern Computer From First Principles.

Support Vector Machines

2x x l. Module 3: Element Properties Lecture 4: Lagrange and Serendipity Elements

Course Introduction. Algorithm 8/31/2017. COSC 320 Advanced Data Structures and Algorithms. COSC 320 Advanced Data Structures and Algorithms

LECTURE NOTES Duality Theory, Sensitivity Analysis, and Parametric Programming

such that is accepted of states in , where Finite Automata Lecture 2-1: Regular Languages be an FA. A string is the transition function,

Classification / Regression Support Vector Machines

Steps for Computing the Dissimilarity, Entropy, Herfindahl-Hirschman and. Accessibility (Gravity with Competition) Indices

News. Recap: While Loop Example. Reading. Recap: Do Loop Example. Recap: For Loop Example

Introduction to Programming. Lecture 13: Container data structures. Container data structures. Topics for this lecture. A basic issue with containers

y and the total sum of

Solving two-person zero-sum game by Matlab

Assignment # 2. Farrukh Jabeen Algorithms 510 Assignment #2 Due Date: June 15, 2009.

A Similarity-Based Prognostics Approach for Remaining Useful Life Estimation of Engineered Systems

AMath 483/583 Lecture 21 May 13, Notes: Notes: Jacobi iteration. Notes: Jacobi with OpenMP coarse grain

Machine Learning 9. week

Outline. Self-Organizing Maps (SOM) US Hebbian Learning, Cntd. The learning rule is Hebbian like:

Excel 2016 Advanced. Course Objectives

Loop Transformations, Dependences, and Parallelization

CS221: Algorithms and Data Structures. Priority Queues and Heaps. Alan J. Hu (Borrowing slides from Steve Wolfman)

CMPS 10 Introduction to Computer Science Lecture Notes

Loop Transformations for Parallelism & Locality. Review. Scalar Expansion. Scalar Expansion: Motivation

Outline. Midterm Review. Using Excel. Midterm Review: Excel Basics. Using VBA. Sample Exam Question. Midterm Review April 4, 2014

Outline. More on Excel. Review Entering Formulas. Review Excel Basics Home tab selected here Tabs Different ribbon commands. Copying Formulas (2/2)

Outline. Discriminative classifiers for image recognition. Where in the World? A nearest neighbor recognition example 4/14/2011. CS 376 Lecture 22 1

9. BASIC programming: Control and Repetition

Biostatistics 615/815

Outline. CIS 110: Introduction to Computer Programming. Review: Interactive Sum. More Cumulative Algorithms. Interactive Sum Trace (2)

Feature-Based Matrix Factorization

Harvard University CS 101 Fall 2005, Shimon Schocken. Assembler. Elements of Computing Systems 1 Assembler (Ch. 6)

A Fast Visual Tracking Algorithm Based on Circle Pixels Matching

Dijkstra s Single Source Algorithm. All-Pairs Shortest Paths. Dynamic Programming Solution. Performance. Decision Sequence.

Array transposition in CUDA shared memory

Mathematics 256 a course in differential equations for engineering students

Lecture #15 Lecture Notes

Content Based Image Retrieval Using 2-D Discrete Wavelet with Texture Feature with Different Classifiers

R s s f. m y s. SPH3UW Unit 7.3 Spherical Concave Mirrors Page 1 of 12. Notes

Assembler. Shimon Schocken. Spring Elements of Computing Systems 1 Assembler (Ch. 6) Compiler. abstract interface.

Proper Choice of Data Used for the Estimation of Datum Transformation Parameters

3D vector computer graphics

APPLICATION OF MULTIVARIATE LOSS FUNCTION FOR ASSESSMENT OF THE QUALITY OF TECHNOLOGICAL PROCESS MANAGEMENT

REFRACTION. a. To study the refraction of light from plane surfaces. b. To determine the index of refraction for Acrylic and Water.

A Robust LS-SVM Regression

Dijkstra s Single Source Algorithm. All-Pairs Shortest Paths. Dynamic Programming Solution. Performance

Lecture 15: Memory Hierarchy Optimizations. I. Caches: A Quick Review II. Iteration Space & Loop Transformations III.

U.C. Berkeley CS294: Beyond Worst-Case Analysis Handout 5 Luca Trevisan September 7, 2017

Exercises (Part 4) Introduction to R UCLA/CCPR. John Fox, February 2005

Oracle Database: SQL and PL/SQL Fundamentals Certification Course

Compiler Design. Spring Register Allocation. Sample Exercises and Solutions. Prof. Pedro C. Diniz

Mode III fracture mechanics analysis with Fourier series method

Parallelism for Nested Loops with Non-uniform and Flow Dependences

A mathematical programming approach to the analysis, design and scheduling of offshore oilfields

ON SOME ENTERTAINING APPLICATIONS OF THE CONCEPT OF SET IN COMPUTER SCIENCE COURSE

Computer Animation and Visualisation. Lecture 4. Rigging / Skinning

A SYSTOLIC APPROACH TO LOOP PARTITIONING AND MAPPING INTO FIXED SIZE DISTRIBUTED MEMORY ARCHITECTURES

Monte Carlo Rendering

On Some Entertaining Applications of the Concept of Set in Computer Science Course

X- Chart Using ANOM Approach

Private Information Retrieval (PIR)

SURFACE PROFILE EVALUATION BY FRACTAL DIMENSION AND STATISTIC TOOLS USING MATLAB

VBA Handout. References, tutorials, books. Code basics. Conditional statements. Dim myvar As <Type >

Excel Functions & Tables

Lecture - Data Encryption Standard 4

Motivation. EE 457 Unit 4. Throughput vs. Latency. Performance Depends on View Point?! Computer System Performance. An individual user wants to:

Robust Parameter Design Methodology for Microwave Circuits Considering the Manufacturing Variations

BIN XIA et al: AN IMPROVED K-MEANS ALGORITHM BASED ON CLOUD PLATFORM FOR DATA MINING

Accounting for the Use of Different Length Scale Factors in x, y and z Directions

MIXED INTEGER-DISCRETE-CONTINUOUS OPTIMIZATION BY DIFFERENTIAL EVOLUTION Part 1: the optimization method

Kent State University CS 4/ Design and Analysis of Algorithms. Dept. of Math & Computer Science LECT-16. Dynamic Programming

An Iterative Solution Approach to Process Plant Layout using Mixed Integer Optimisation

Computer models of motion: Iterative calculations

COMPARISON OF A MACHINE OF MEASUREMENT WITHOUT CONTACT AND A CMM (1) : OPTIMIZATION OF THE PROCESS OF METROLOGY.

Introduction to Geometrical Optics - a 2D ray tracing Excel model for spherical mirrors - Part 2

Detection of hand grasping an object from complex background based on machine learning co-occurrence of local image feature

Consolidate and Summarizing Data from Multiple Worksheets

RECONSTRUCTION OF 3D TUBULAR STRUCTURES FROM CONE-BEAM PROJECTIONS

Complex Numbers. Now we also saw that if a and b were both positive then ab = a b. For a second let s forget that restriction and do the following.

3/31/2016. Spreadsheets. Spreadsheets. Spreadsheets and Data Management. Unit 3. Can be used to automatically

Parallel Numerics. 1 Preconditioning & Iterative Solvers (From 2016)

Microsoft Office Excel Create a worksheet group. A worksheet group. Tutorial 6 Working With Multiple Worksheets and Workbooks

Integrated Expression-Invariant Face Recognition with Constrained Optical Flow

Computer Vision. Exercise Session 1. Institute of Visual Computing

Recognizing Faces. Outline

Intro. Iterators. 1. Access

Installation and User Guide. Digidim Remote Control (303) Product description. Switching Lights On/Off using Digidim 303 Remote

Improvement of Spatial Resolution Using BlockMatching Based Motion Estimation and Frame. Integration

Excel Formulas & Functions I CS101

Line Clipping by Convex and Nonconvex Polyhedra in E 3

SVM-based Learning for Multiple Model Estimation

This module is part of the. Memobust Handbook. on Methodology of Modern Business Statistics

Simulation: Solving Dynamic Models ABE 5646 Week 11 Chapter 2, Spring 2010

Transcription:

Programmng Assgnment Sx, 07 Programmng Assgnment Sx Larry Caretto Mechancal Engneerng 09 Computer Programmng for Mechancal Engneers Outlne Practce quz for actual quz on Thursday Revew approach dscussed last class for passng worksheet arrays as nput arguments n a VBA functon Revew programmng assgnment sx Work on programmng assgnment sx, 07 Semester Calendar Date Assgnment Date Assgnment 9 Assgnment 6 Due 4 8 Quz 5 on Arrays Programmng Exam Fnal Exam :45 to :45 pm Sub samplearrayquz() Dm x( To 00) As Double Dm k As Long, row As Long Dm col As Long x(k) = k ^ + * k ext k For col = To 5 Step Show output from sub on worksheet ext col ext row End Sub 3 4 Revew VBA Arrays from Excel Wll be two-dmensonal VBA arrays unless cells method used to set values for one-dmensonal array For range.value or range nput argument Frst array ndex wll run from to number of rows Second array ndex wll run from to number of columns Range wth only one row or one column wll stll be two-dmensonal array 5 D Excel Worksheet Arrays What happens when we use the column array x or the row array y as an nput to a VBA functon? 6 ME 09 Computer Programmng for Mechancal Engneers

Programmng Assgnment Sx, 07 VBA Functon to Read x and y Functon readarrays(xin As Range, _ yin As Range) As Double Dm x As Varant, y As Varant Dm nrows As Long, ncols As Long x = xin nrows = UBound(x,) ncols = UBound(x,) y = yin nrows = UBound(y,) ncols = UBound(y,) 7 Readng Column Array (Debug) The second argument to the ubound functon s for the frst dmenson of a D array and for the second dmenson 8 Readng Column Array (Debug) Readng Row Array (Debug) 9 0 Readng Row Array (Debug) y Programmng Assgnment Sx See onlne assgnment for detals Ft straght lne to expermental data Workbook pa6start.xlsm has data and shell for functon Equaton of ftted lne: Equatons to use for assgnment: y x x x y ( x b yˆ y x ( x) R y y )( y) a y bx ME 09 Computer Programmng for Mechancal Engneers

Programmng Assgnment Sx, 07 Programmng Assgnment Sx II Download workbook pa6start.xlsm wth VBA shell for array functon Create functon that reads worksheet data nto type Varant arrays x and y Copy approach used n lectures Do calculatons for a, b, and R usng ths array data Use worksheet shell statements to create your own array functon 3 Assgnment Sx Code Shell Functon <yourfunctoname> _ ( <arguments> ) as Varant Dm output( To 3, To ) As Varant <put code for computatons here> output(, ) = " Slope = " output(, ) = "Intercept = " output(3, ) = "R-squared = " output(, ) = <Result for b> output(, ) = <Result for a> output(3, ) = <Result for R^> <yourfunctoname> = output End Functon 4 Program Desgn All equatons shown below have sums of data (or calculatons from data) over same set of (x, y ), =, All calculatons can be done n a sngle For loop except for R numerator yˆ y y y x yˆ y R y y x b x y ( x)( y) x ( x) a y bx 5 Array Functons An Excel array functon s one whch produces values n two or more cells Example s Lnest regresson functon Select multple cells (here D:E5) for output, enter formula, Practce: and press Copy data Ctrl+Shft+Enter from F:G6 and enter array formula n D:E5 6 Result of Lnest Array Functon Output results from array formula See Help for Lnest functon to get meanng of all results for statstcal lne ft of ths functon Input range from prevous slde Ftted lne for data s 0.74.08 Wth R = 0.99557 7 Sub samplearrayquz() Dm x( To Sample 00) As Quz Double What s output Dm k As Long, row As Long from ths sub? Dm col As Long x(k) = k ^ + * k x array s ext k defned here For col = To 5 Step ext col Values of x array sent ext row to worksheet here End Sub 8 ME 09 Computer Programmng for Mechancal Engneers 3

Programmng Assgnment Sx, 07 Sub samplearrayquz() Dm x( To Sample 00) As Quz Double Dm k As Long, row As Long Dm col As Long x(k) = k ^ + * k ext k and 0 Row loop wll produce output n rows, 4, 7 For col = To 5 Step ext col Col loop wll produce output ext row n columns, 3 and 5 End Sub (columns A, C, and E) 9 Sub samplearrayquz() Dm x( To Sample 00) As Quz Double Dm k As Long, row As Long Dm col As Long x(k) = k ^ + * k ext k For row n =, 3, and 5 For col = To 5 Step ext col So x(k) for k =, 3, 5 s ext row + () = 3, 3 + (3) =5, End Sub and 5 + (5) = 35 0 Frst Row of Output Sub samplearrayquz() Dm x( To Sample 00) As Quz Double Dm k As Long, row As Long Dm col As Long x(k) = k ^ + * k ext k For row 4 n = 4,, and 0 For col = To 5 Step ext col So x(k) for k = 4,, 0 s 4 ext row + (4) = 4, + () End Sub =68, and 0 + (0) = 440 Frst Two Rows of Output 3 Sub samplearrayquz() Dm x( To Sample 00) As Quz Double Dm k As Long, row As Long Dm col As Long x(k) = k ^ + * k ext k For row 7 n = 7,, and 35 For col = To 5 Step ext So col x(k) for k = 7,, 35 s 7 + (7) ext = row 63, + () = 483, and 35 + End Sub(35) = 95 4 ME 09 Computer Programmng for Mechancal Engneers 4

Programmng Assgnment Sx, 07 Frst Three Rows of Output 5 Sub samplearrayquz() Dm x( To Sample 00) As Quz Double Dm k As Long, row As Long Dm col As Long x(k) = k ^ + * k ext k For row 0 n = 0, 30, and 50 For col = To 5 Step ext So col x(k) for k = 0, 30, 50 s 0 + ext (0) row = 0, 30 + (30) = 960, and End Sub50 + (50) = 600 6 Complete Output from Sub 7 ME 09 Computer Programmng for Mechancal Engneers 5