INTRODUCTION TO NUMERICAL ANALYSIS

Similar documents
Introduction to MATLAB LAB 1

Mechanical Engineering Department Second Year (2015)

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

Desktop Command window

Matlab Programming Introduction 1 2

Introductory MATLAB. Appendix A A.1 BACKGROUND A.2 STARTING WITH MATLAB. Core Topics

Introduction to. The Help System. Variable and Memory Management. Matrices Generation. Interactive Calculations. Vectors and Matrices

Constraint-based Metabolic Reconstructions & Analysis H. Scott Hinton. Matlab Tutorial. Lesson: Matlab Tutorial

Matlab Tutorial and Exercises for COMP61021

Matlab Tutorial for COMP24111 (includes exercise 1)

Programming in Mathematics. Mili I. Shah

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

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

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

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

Chapter 1 Introduction to MATLAB

PART 1 PROGRAMMING WITH MATHLAB

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

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

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

MATLAB - Lecture # 4

Physics 326G Winter Class 2. In this class you will learn how to define and work with arrays or vectors.

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

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

A Tutorial on Matlab Ch. 3 Programming in Matlab

Introduction to MATLAB

To start using Matlab, you only need be concerned with the command window for now.

Matlab notes Matlab is a matrix-based, high-performance language for technical computing It integrates computation, visualisation and programming usin

Introduction to MATLAB

Introduction to MATLAB for Numerical Analysis and Mathematical Modeling. Selis Önel, PhD

Matlab Tutorial: Basics

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

Introduction to MATLAB Practical 1

Computational Photonics, Seminar 01 on Introduction into MATLAB, Page 1

User Defined Functions

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

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

Lecturer: Keyvan Dehmamy

MATLAB Lesson I. Chiara Lelli. October 2, Politecnico di Milano

Introduction to MATLAB

Finding, Starting and Using Matlab

MATLAB Vocabulary. Gerald Recktenwald. Version 0.965, 25 February 2017

CME 192: Introduction to Matlab

Introduction to Engineering gii

MATLAB Introduction To Engineering for ECE Topics Covered: 1. Creating Script Files (.m files) 2. Using the Real Time Debugger

An Introduction to MATLAB

The Mathematics of Big Data

Introduction to MatLab. Introduction to MatLab K. Craig 1

What is Matlab? The command line Variables Operators Functions

MATLAB TUTORIAL WORKSHEET

Introduction to MATLAB. Computational Probability and Statistics CIS 2033 Section 003

Getting started with MATLAB

Prof. Manoochehr Shirzaei. RaTlab.asu.edu

Programming 1. Script files. help cd Example:

FOR LOOP. for <indexmin:indexstep:indexmax> {statements} end

A Brief Introduction to MATLAB

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

Introduction to MATLAB

MATLAB Tutorial. Digital Signal Processing. Course Details. Topics. MATLAB Environment. Introduction. Digital Signal Processing (DSP)

MATLAB BASICS. < Any system: Enter quit at Matlab prompt < PC/Windows: Close command window < To interrupt execution: Enter Ctrl-c.

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

Inlichtingenblad, matlab- en simulink handleiding en practicumopgaven IWS

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

Matlab Tutorial. The value assigned to a variable can be checked by simply typing in the variable name:

EGR 111 Introduction to MATLAB

MATLAB. MATLAB Review. MATLAB Basics: Variables. MATLAB Basics: Variables. MATLAB Basics: Subarrays. MATLAB Basics: Subarrays

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

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

Introduction to Matlab. By: Hossein Hamooni Fall 2014

MATLAB PROGRAMMING LECTURES. By Sarah Hussein

Introduction to Computer Programming with MATLAB Matlab Fundamentals. Selis Önel, PhD

Introduction to GNU-Octave

Quick MATLAB Syntax Guide

MATLAB Guide to Fibonacci Numbers

Introduction to Matlab. WIAA Technical Workshop #2 10/20/2015

Matlab 1: Get Started

PROGRAMMING WITH MATLAB DR. AHMET AKBULUT

Welcome to EGR 106 Foundations of Engineering II

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

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

Outline. User-based knn Algorithm Basics of Matlab Control Structures Scripts and Functions Help

Introduction to MATLAB programming: Fundamentals

! The MATLAB language

Introduction to Matlab

Here is a quick introduction to Matlab and a couple of its symbolic and control functions.

QUICK INTRODUCTION TO MATLAB PART I

UNIVERSITI TEKNIKAL MALAYSIA MELAKA FAKULTI KEJURUTERAAN ELEKTRONIK DAN KEJURUTERAAN KOMPUTER

MATLAB GUIDE UMD PHYS401 SPRING 2012

MATLAB for beginners. KiJung Yoon, 1. 1 Center for Learning and Memory, University of Texas at Austin, Austin, TX 78712, USA

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

ME 121 MATLAB Lesson 01 Introduction to MATLAB

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

MATLAB Introduction to MATLAB Programming

Matlab Lecture 1 - Introduction to MATLAB. Five Parts of Matlab. Entering Matrices (2) - Method 1:Direct entry. Entering Matrices (1) - Magic Square

MatLab Just a beginning

INTRODUCTION TO MATLAB PLOTTING WITH MATLAB

Some elements for Matlab programming

Lecture 2 Introduction to MATLAB. Dr.Tony Cahill

CSE/NEUBEH 528 Homework 0: Introduction to Matlab

What is Matlab? A software environment for interactive numerical computations

Transcription:

INTRODUCTION TO NUMERICAL ANALYSIS Cho, Hyoung Kyu Department of Nuclear Engineering Seoul National University

0. MATLAB USAGE

1. Background MATLAB MATrix LABoratory Mathematical computations, modeling and simulations, data analysis and processing, visualization and graphics, and algorithm development Standard MATLAB Toolboxes Signal processing, symbolic calculations, control system, image processing, etc.

MATLAB download 2. Starting with MATLAB

2. Starting with MATLAB MATLAB interface Current directory window Editor window Workspace window Command window Command history window

2. Starting with MATLAB Command window Commands are typed next to the prompt (>>) and are executed when the Enter key is pressed. Output generated by the command is displayed in the Command Window, unless a semicolon ( ; ) is typed at the end. clc command: clear Command Window Up-arrow and down-arrow keys ( and ): recall commands typed before

2. Starting with MATLAB Command window Numerical values can be assigned to variables. Elementary math built-in functions Ex) sqrt(x)

Built-in elementary math functions 2. Starting with MATLAB

Built-in elementary math functions 2. Starting with MATLAB

Display format 2. Starting with MATLAB

3. Arrays Arrays 1D array: vector 2D array: matrix Each number in a vector or a matrix: element Creating a vector in MATLAB Row vector variable_name=[number; number; number] ; is placed! Column vector Row vector with constant spacing m : first element q : spacing n : last element

3. Arrays Arrays Creating a vector in MATLAB linspace command xi : first element xf : final element n : number of elements

3. Arrays Arrays Creating a matrix in MATLAB Variables and mathematical expressions can be used as elements. Array addressing

3. Arrays Arrays Array addressing

3. Arrays Arrays Array addressing Using a colon : in addressing arrays

3. Arrays Arrays Built-in functions for handling arrays size(a,1) size(a,2)

3. Arrays Strings A string is an array of characters. It is created by typing the characters within single quotes. Strings can include letters, digits, other symbols, and spaces. Concatenate strings horizontally strcat : string concatenate! How can create Nuclear Engineering using strcat command? 32?

Addition and subtraction of arrays 4. Mathematical Operations with Arrays

Multiplications of arrays 4. Mathematical Operations with Arrays

4. Mathematical Operations with Arrays Array division ( / ) Element-by-element operations

4. Mathematical Operations with Arrays Element-by-element operations Usefulness of element-by-element operation For example,

Built-in functions for handling arrays 4. Mathematical Operations with Arrays

5. Script Files Script file Program: a file that contains a sequence of MATLAB commands Extension:.m M-file

5. Script Files Script file Input to a script file Define the variable and assign it a value in the script file File must be edited and the assignment of the variable changed. Define the variable and assign it a value in the Command Window

5. Script Files Script file Input to a script file Define the variable in the script file but assign a specific value in the Command Window when the script file is executed. input command

5. Script Files Script file Output from a script file disp command fprintf command To Command Window To a file New line New line of text file

6. Plotting Plots in MATLAB Standard plots with linear axes and logarithmic axes Bars and stairs plots plot command With line specifiers

6. Plotting Plots in MATLAB plot command With line specifiers, labels, title plot(x,y,'r') xlabel('x') ylabel('y') title('test') y=[5 10.2 7 8 6 5 3 1]; hold on plot(x,y,'ob-') vs figure,plot(x,y, ob- ) plot(x,y,'*m--') xlim([0 12]) ylim([0 10]) or axis([0 12 0 10]) xlabel('x','fontsize',20, 'FontWeight','bold','Color','r')

6. Plotting Plots in MATLAB plot3 command >> t = 0:pi/50:10*pi; >> st = sin(t); >> ct = cos(t); >> figure >> plot3(st,ct,t)

Plots in MATLAB surf command Meshgrid(-1:0.5:1); 6. Plotting >> k = 6; >> n = 2^k-1; >> [x,y,z] = sphere(n); >> figure >> surf(x,y,z); [x,y]=meshgrid(-8:0.5:8); r=sqrt(x.^2+y.^2)+eps; z=sin(r)./r; surf(x,y,z); Figure Window n by n sphere

7. User-defined Functions and Function Files User defined function Arguments To create user-defined function Similar with script files

7. User-defined Functions and Function Files User defined function Simple example of function test.m function [result1 result2]=test(a) result1=a+100; result2=a+200; Command Window [a b]=test(100) a = 200 b = 300

Anonymous Functions 8. Anonymous Functions Users can define functions in the Command Window, within a script file or inside a userdefined function cube= @ (x) x^3 circle=@ (x, y) 16*x^2+9*y^2 parabola= @ (x) a*x^2+b*x+c FA= @ (x) exp(x^2)/sqrt(x^2+5) >> FA(2) ans = 18.1994 >> z=fa(3) z = 2.1656e+03

Function function Function that accepts a function handle as an input argument Function handle Ex) coshandle=@cos 9. Function Functions fhandle=@(x)(2*x); fplot(fhandle,[0.0,1.0]) hold on fhandle=@(x)(sin(1.0/x)); fplot(fhandle,[0.0001,1.0]) ylim([-2,2])

10. Programming in MATLAB Relational and logical operators >> 4==5 ans = 0 >> 5>10 ans = 0 >> 0 1 ans = 1 >> 0&1 ans = 0 >> 1&5 ans = 1 >> 1 2 ans = 1 >> ~(1 0) ans = 0

10. Programming in MATLAB Conditional Statements, if-else Structures if-end if-else-end if-elseif-else-end if-elseif-elseif -else-end In a script file, function test(a) if(a<10) 'less than 0' elseif(a<10) 'greater than 0, less than 10' elseif(a<100) 'greater than 10, less than 100' else 'greater than or equal to 100' end

10. Programming in MATLAB Loops for-end function circle(r) n=100; for i=1:n theta=2*pi/n*i; x(i)=r*cos(theta); y(i)=r*sin(theta); end plot(x,y) 원을쌓아구를그려보길.