Introduction to Literate Programming in Matlab 2WN50 – Week 1 https://www.dropbox.com/s/vvhp3ldlpfterna/ 01-programming-in-matlab.pptx?dl=0.

Slides:



Advertisements
Similar presentations
Introduction to Matlab
Advertisements

Why python? Automate processes Batch programming Faster Open source Easy recognition of errors Good for data management What is python? Scripting programming.
Flow Charts, Loop Structures
Scripts and Flow Control. Scripts So far we have been entering commands directly into the command line But there is a better way Script files (and functions)
MATLAB ME1107 Y Yan Reference: MATLAB for Engineers by Holly Moore (Pearson Prentice Hall)
Introduction to Matlab By: Dr. Maher O. EL-Ghossain.
General Computer Science for Engineers CISC 106 Lecture 08 Dr. John Cavazos Computer and Information Sciences 2/27/2009.
Guide To UNIX Using Linux Third Edition
MATLAB and Simulinklecture 31 To days Outline  Functions  Strings  Sparse Arrays  Cell Arrays  Structures  Exercises on this days topics.
Introduction to MATLAB MECH 300H Spring Starting of MATLAB.
Principles of Procedural Programming
Introduction to programming in MATLAB MATLAB can be thought of as an super-powerful graphing calculator Remember the TI-83 from calculus? With many more.
Lecture 1: Introduction Lecture series based on the text: Essential MATLAB for Engineers and Scientists By Hahn & Valentine
M-files While commands can be entered directly to the command window, MATLAB also allows you to put commands in text files called M- files. M-files are.
Matlab tutorial course Exercises 1:. Exercises Go back to my webpage, download the file ‘startup.m’ and save it in your MATLAB home folder – Must be directly.
Matlab tutorial course Exercises 2:. Exercises Copy the script ‘face_points.m’ from my webpage into your ‘scripts’ folder Create a new folder in your.
Introduction to Matlab & Data Analysis
Recap Graphic Window Edit Window Start Button Matrices in MATLAB Scalar Operations Order of Operations Array Operations Matrix Addition Matrix Multiplication.
1 Functions 1 Parameter, 1 Return-Value 1. The problem 2. Recall the layout 3. Create the definition 4. "Flow" of data 5. Testing 6. Projects 1 and 2.
Introduction to Engineering MATLAB – 6 Script Files - 1 Agenda Script files.
Matlab Workshop 1/10/07 Lesson 1: Matlab as a graphing calculator.
Numerical Computation Lecture 2: Introduction to Matlab Programming United International College.
Introduction to MATLAB Session 3 Simopekka Vänskä, THL Department of Mathematics and Statistics University of Helsinki 2011.
Introduction to MATLAB 7 Engineering 161 Engineering Practices II Joe Mixsell Spring 2010.
10/24/20151 Chapter 2 Review: MATLAB Environment Introduction to MATLAB 7 Engineering 161.
MATLAB Harri Saarnisaari, Part of Simulations and Tools for Telecommunication Course.
Synthesis ENGR 1181 MATLAB 11. Topics  No new material  Covers topics that will be on the Midterm 2 Exam MATLAB 01 – Program Design MATLAB 02 – Introduction.
MATLAB Environment ELEC 206 Computer Applications for Electrical Engineers Dr. Ron Hayne.
Computational Methods of Scientific Programming Lecturers Thomas A Herring, Room , Chris Hill, Room ,
Winter Semester 2014/2015 College of Engineering.
Scientific Computing Introduction to Matlab Programming.
Chapter 3 MATLAB Fundamentals Introduction to MATLAB Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Chapter 3 Functions, Events, and Control Structures JavaScript, Third Edition.
Chapter 1 – Matlab Overview EGR1302. Desktop Command window Current Directory window Command History window Tabs to toggle between Current Directory &
Chapter 6 Review: User Defined Functions Introduction to MATLAB 7 Engineering 161.
MCE 372 Engineering Analysis MATLAB Review. M ATLAB – What Is It ? Where Is It? Name is from matrix laboratory Powerful tool for – Computation and visualization.
Introduction to MATLAB 7 MATLAB Programming for Engineer Hassan Migdadi Spring 2013.
1 Lecture 1 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept.
Introduction to Matlab  Matlab is a software package for technical computation.  Matlab allows you to solve many numerical problems including - arrays.
Introduction to MATLAB 7 Engineering 161 Engineering Practices II Joe Mixsell Spring 2012.
Introduction to Matlab
XP New Perspectives on XML, 2 nd Edition Tutorial 7 1 TUTORIAL 7 CREATING A COMPUTATIONAL STYLESHEET.
Introduction to MATLAB Section2, statistics course Third year biomedical dept. Dina El Kholy, Ahmed Dalal.
INTRODUCTION TO MATLAB Dr. Hugh Blanton ENTC 4347.
1 Lecture 4 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept.
1 Lecture 5 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept.
M ATLAB – What Is It ? Name is from matrix laboratory Powerful tool for – Computation and visualization of engineering and science mathematics – Communication.
NMD202 Web Scripting Week2. Web site
Chapter 4 MATLAB Programming MATLAB Troubleshooting Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Introduction to Programming on MATLAB Ecological Modeling Course Sep 11th, 2006.
Creating a script create new blank document. Editor options Docking and undocking tabs.
M ATLAB – What Is It ? Name is from matrix laboratory Powerful tool for – Computation and visualization of engineering and science mathematics – Communication.
Introduction to Matlab PHY September Why Matlab? No need to compile code Huge amount of built-in functions Highly optimized and fast, in general.
SKMM1013 Programming for Engineers
Introduction to Programming
Computer Application in Engineering Design
Lecture 25.
Think What will be the output?
Lecture 1: Introduction
MATLAB – What Is It ? Name is from matrix laboratory Powerful tool for
MATLAB – What Is It ? Name is from matrix laboratory Powerful tool for
MATLAB – What Is It ? Name is from matrix laboratory Powerful tool for
Functions In Matlab.
Matlab tutorial course
Introduction to Programming
Very Old Introduction to Matlab for EGR 220
CSCI N317 Computation for Scientific Applications Unit 1 – 1 MATLAB
CSCI N207 Data Analysis Using Spreadsheet
Scripts In Matlab.
Introduction to Programming
Presentation transcript:

Introduction to Literate Programming in Matlab 2WN50 – Week programming-in-matlab.pptx?dl=0

2 Assignment: implement Regula Falsi Explore the following problem (i.e. graphs, tables) and implement it in Matlab

3 Matlab: command window

4 Command window

5 Matlab: command window Command window Files in current folder Variables that are currently defined

6 Matlab basics: the command window

7

8

9

10 Matlab basics: arrays

11 Matlab basics: arrays

12 Matlab basics: arrays

13 Matlab basics: arrays

14 Matlab basics: arrays

15 Matlab basics: arrays

16 Matlab basics: arrays++

17 Matlab basics: arrays++

18 Matlab basics: arrays++ Operations on arrays are much faster than for- loops!

19 Matlab basics: arrays++

20 Matlab basics: arrays++

21 Assignment: implement Regula Falsi Explore the following problem (i.e. graphs, tables) and implement it in Matlab Exercise 1: Plot this function with 65 points on the given interval.

22 Matlab basics: arrays++

23 Matlab basics: functions

24 Matlab: command window Command window Files in current folder Variables that are currently defined Editor

25 Matlab: command window Command window Files in current folder Variables that are currently defined Editor ➊ ➋

26 Matlab basics: functions

27 Matlab basics: functions

28 Matlab basics: functions

29 Matlab basics: functions

Function can be Made as external m-file o Document/comment in-between steps o Function can have ‘side-effects’ (e.g. make a plot) o Suitable for functions that do “complex” operations  Check arguments  Need to use if/for etc Define inline o Short notation o Refer to coefficients in the current scope o Suitable for functions in mathematical sense.  Direct mapping of output to input 30 Matlab basics: functions

31 Matlab basics: exercise 2

32 Matlab basics: programming

33 Matlab basics: programming

34 Matlab basics: programming

35 Matlab basics: programming

36 Matlab basics: programming

CELL based editing o Collect commands rather than type them in command window o Adjust order, adjust form  E.g. plots you want to change title, labels, add elements iteratively o Execute small pieces of code rather than whole file o Code is publishable to a readable format 37 Matlab basics: programming

38 Matlab basics: literate programming

39 Matlab basics: literate programming

40 Matlab basics: literate programming PUBLISH publishing.html#btj5jsh-1

41 Matlab basics: programming

42 Assignment: implement Regula Falsi Explore the following problem (i.e. graphs, tables) and implement it in Matlab Exercise 3: Implement REGULA FALSI in a cell based script. Write introduction with problem statement in LaTeX.

43 Assignment: implement Regula Falsi (alt.) Explore the following problem (i.e. graphs, tables) and implement it in Matlab BONUS: Why is this formulation better?

44 Sample implementation

Refer to an m-file as function object e.g. Arguments are passed as copies, so changing the value of arguments inside a function does not change it outside of the function. Include m-files in published document with % myfunc.m 45 Addenda

Short Matlab introduction – Language basics – Programming concepts – Literate programming The assignments (2WN52) are to be implemented and handed in as a document published with Matlab. 46 Summary