MATLAB. What is MATLAB? MATLAB is a simple programming language with its own extensive library of mathematical and graphical subroutines It integrates.

Slides:



Advertisements
Similar presentations
6-1 指標簡介 6-2 指標與陣列 6-3 動態配置記憶體 6-4 本章綜合練習
Advertisements

布林代數的應用--- 全及項(最小項)和全或項(最大項)展開式
Introduction to Java Programming Lecture 13 Classes I OO Programming.
Section 1.2 Describing Distributions with Numbers 用數字描述分配.
PowerPoint2010 李燕秋 版面配置 版面配置指的是每一個頁面的內容配置 方式,不同的版面配置會有對應的母片。
如何將數字變成可用之資訊 現代化資料處理與應用概念. 如何將數字變成可用之資訊 人最容易接受的訊息是圖像化資訊。 在一堆數字中,要進行比較分析,一般會使用表格形 式計算與分析。 所以一般我們會將數字依關聯性, 轉換成表格計算與分析。 此表格一般稱試算表或稱表格。 再將結果轉換為圖表,進行比較與分析。
1.1 線性方程式系統簡介 1.2 高斯消去法與高斯-喬登消去法 1.3 線性方程式系統的應用(-Skip-)
Lecture 8 Median and Order Statistics. Median and Order Statistics2 Order Statistics 問題敘述 在 n 個元素中,找出其中第 i 小的元素。 i = 1 ,即為找最小值。 i = n ,即為找最大值。 i = 或 ,即為找中位數。
:New Land ★★★★☆ 題組: Problem Set Archive with Online Judge 題號: 11871: New Land 解題者:施博修 解題日期: 2011 年 6 月 8 日 題意:國王有一個懶兒子,為了勞動兒子,他想了一個 辦法,令他在某天早上開始走路,直到太陽下山前,靠.
: OPENING DOORS ? 題組: Problem Set Archive with Online Judge 題號: 10606: OPENING DOORS 解題者:侯沛彣 解題日期: 2006 年 6 月 11 日 題意: - 某間學校有 N 個學生,每個學生都有自己的衣物櫃.
Chapter 2 聯立線性方程式與矩陣 緒言 線性方程式組 (systems of linear equations) 出現 在多數線性模式 (linear model) 中。根據以往解 題的經驗,讀者們也許已發現方程式的解僅與 該方程式的係數有關,求解的過程也僅與係數 的運算有關,只要係數間的相關位置不改變,
STAT0_sampling Random Sampling  母體: Finite population & Infinity population  由一大小為 N 的有限母體中抽出一樣本數為 n 的樣 本,若每一樣本被抽出的機率是一樣的,這樣本稱 為隨機樣本 (random sample)
: Matrix Decompressing ★★★★☆ 題組: Contest Volumes with Online Judge 題號: 11082: Matrix Decompressing 解題者:蔡權昱、劉洙愷 解題日期: 2008 年 4 月 18 日 題意:假設有一矩陣 R*C,
5.1 Rn上之長度與點積 5.2 內積空間 5.3 單範正交基底:Gram-Schmidt過程 5.4 數學模型與最小平方分析
第一章 信號與系統初論 信號的簡介與DSP的處理方式。 系統特性與穩定性的判定方法。 以MATLAB驗證系統的線性、非時變、因果等特性。
MATLAB 程式設計 第 11 章 多維陣列 多維陣列的定義 在 MATLAB 的資料型態中,向量可視為 一維陣列,矩陣可視二維陣列,對於維 度 (Dimensions) 超過 1 的陣列則均可視 為「多維陣列」 (Multidimesional Arrays , 簡稱 N-D Arrays)
8.1 何謂高度平衡二元搜尋樹 8.2 高度平衡二元搜尋樹的加入 8.3 高度平衡二元搜尋樹的刪除
空間域之影像強化 3.1 背景介紹 3.2 基礎灰階值轉換 3.3 以灰階統計圖為基礎之處理 3.4 算術與邏輯運算 3.5 基礎空間域濾波
南投縣社區大學 Excel 實務應用入門 講師 : 林泉成
第 1 章 PC 的基本構造. 本章提要 PC 系統簡介 80x86 系列 CPU 及其暫存器群 記憶體: Memory 80x86 的分節式記憶體管理 80x86 的 I/O 結構 學習組合語言的基本工具.
1 第四章 多變數函數的微分學 § 4.1 偏導數定義 定義 極限值 ■. 2 定理 極限值的基本定理 (1) 極限值的唯一性 : 若 存在,則 其值必為唯一。 (2) 若 且 ( 與 為常數 ) , 則 且 為常數且.
Introduction to Java Programming Lecture 17 Abstract Classes & Interfaces.
:Problem D: Bit-wise Sequence ★★★☆☆ 題組: Problem Set Archive with Online Judge 題號: 10232: Problem D: Bit-wise Sequence 解題者:李濟宇 解題日期: 2006 年 4 月 16.
Introduction to MATLAB 3 November Instructor: Andy Newman Office Hours: Stop by room 306 (main building) whenever
: Happy Number ★ ? 題組: Problem Set Archive with Online Judge 題號: 10591: Happy Number 解題者:陳瀅文 解題日期: 2006 年 6 月 6 日 題意:判斷一個正整數 N 是否為 Happy Number.
Digital Signal Processing with Examples in M ATLAB ® Chap 1 Introduction Ming-Hong Shih, Aug 25, 2003.
3.1 矩陣的行列式 3.2 使用基本運算求行列式 3.3 行列式的性質 3.4 特徵值介紹 3.5 行列式的應用
Fourier Series. Jean Baptiste Joseph Fourier (French)(1763~1830)
: Ahoy, Pirates! ★★★★☆ 題組: Contest Archive with Online Judge 題號: 11402: Ahoy, Pirates! 解題者:李重儀 解題日期: 2008 年 8 月 26 日 題意:有一個海盜島有 N 個海盜,他們的編號 (id)
國立清華大學資訊工程學系 2009/10/13P-1 變數與基本運算 Ref: 清大資工系 多媒體檢索實驗室 張智星教授.
: Multisets and Sequences ★★★★☆ 題組: Problem Set Archive with Online Judge 題號: 11023: Multisets and Sequences 解題者:葉貫中 解題日期: 2007 年 4 月 24 日 題意:在這個題目中,我們要定義.
The application of boundary element evaluation on a silencer in the presence of a linear temperature gradient Boundary Element Method 期末報告 指導老師:陳正宗終身特聘教授.
資料結構實習-一 參數傳遞.
Lecture 7 Sorting in Linear Time. Sorting in Linear Time2 7.1 Lower bounds for sorting 本節探討排序所耗用的時間複雜度下限。 任何一個以比較為基礎排序的演算法,排序 n 個元 素時至少耗用 Ω(nlogn) 次比較。
1 Introduction to Java Programming Lecture 2: Basics of Java Programming Spring 2008.
觀測量的權 權的觀念與計算.
公用品.  該物品的數量不會因一人的消費而受到 影響,它可以同時地被多人享用。 角色分配  兩位同學當我的助手,負責:  其餘各人是投資者,每人擁有 $100 , 可以投資在兩種資產上。  記錄  計算  協助同學討論.
: Beautiful Numbers ★★★★☆ 題組: Problem Set Archive with Online Judge 題號: 11472: Beautiful Numbers 解題者:邱經達 解題日期: 2011 年 5 月 5 日 題意: 若一個 N 進位的數用到該.
函式 Function Part.2 東海大學物理系‧資訊教育 施奇廷. 遞迴( Recursion ) 函式可以「呼叫自己」,這種動作稱為 「遞迴」 此程式的執行結果相當於陷入無窮迴圈, 無法停止(只能按 Ctrl-C ) 這給我們一個暗示:函式的遞迴呼叫可以 達到部分迴圈的效果.
Image Interpolation Use SSE 指導教授 : 楊士萱 學 生 : 楊宗峰 日 期 :
資料結構實習-二.
1 第七章 植基於可調整式量化表及離散餘 弦轉換之浮水印技術. 2 Outlines 介紹 介紹 灰階浮水印藏入 灰階浮水印藏入 灰階浮水印取回 灰階浮水印取回 實驗結果 實驗結果.
845: Gas Station Numbers ★★★ 題組: Problem Set Archive with Online Judge 題號: 845: Gas Station Numbers. 解題者:張維珊 解題日期: 2006 年 2 月 題意: 將輸入的數字,經過重新排列組合或旋轉數字,得到比原先的數字大,
Chapter 10 m-way 搜尋樹與B-Tree
: Function Overloading ★★★☆☆ 題組: Problem Set Archive with Online Judge 題號: 11032:Function Overloading 解題者:許智祺 解題日期: 2007 年 5 月 8 日 題意:判對輸入之數字是否為.
本章重點 2-1 有序串列(Ordered List) 2-2 介紹陣列(array) 2-3 矩陣(matrix)的應用
: Help My Brother ★★★☆☆ 題組: Problem Set Archive with Online Judge 題號: 11033: Help My Brother 解題者: 呂明璁 解題日期: 2007 年 5 月 14 日.
1 Introduction to Java Programming Lecture 2: Basics of Java Programming Spring 2009.
計算機概論 第6章 數位邏輯設計.
2005/7 Linear system-1 The Linear Equation System and Eliminations.
5 重複迴圈 5.1 增減運算符號 增量運算符號 減量運算符號
冷凍空調自動控制 - 系統性能分析 李達生. Focusing here … 概論 自動控制理論發展 自控系統設計實例 Laplace Transform 冷凍空調自動控制 控制系統範例 控制元件作動原理 控制系統除錯 自動控制理論 系統穩定度分析 系統性能分析 PID Controller 自動控制實務.
中序轉後序 藉由由左向右掃瞄中序運算式產生後序運算式,遇到 運算元就直接輸出,遇到運算符號則先存入堆疊,將 優先權較高者輸出。 範例: a + b * c TokenStack [0] [1] [2] topoutput aa ++0a b+0ab *+ *1ab c+ *1abc eosabc*+
第 6 章 迴圈結構 6-1 計數迴圈 6-1 計數迴圈 6-2 條件迴圈 6-2 條件迴圈 6-3 巢狀迴圈 6-3 巢狀迴圈 6-4 While/End While 迴圈 6-4 While/End While 迴圈 6-5 跳出迴圈 6-5 跳出迴圈 6-6 VB.NET 的錯誤處理 6-6 VB.NET.
Visual C++重點複習.
資料結構實習-六.
1 Introduction to Java Programming Lecture 3 Mathematical Operators Spring 2008.
Introduction to Matlab Yu-Ting Kuo VLSI Signal Processing Lab, NCTU May. 29, 2007 *source: “ 張智星, Matlab 程式設計與應用, 清蔚科技出版 ”
數學軟體簡介 PART II Matlab 介紹. 今天進度: Matlab 基本環境操作 Matlab 小傳 外觀基本認識 使用變數與基本運算 向量與矩陣的處理 常用數學函數 查詢命令 常用的永久常數.
Microsoft Excel.
: Finding Paths in Grid ★★★★☆ 題組: Contest Archive with Online Judge 題號: 11486: Finding Paths in Grid 解題者:李重儀 解題日期: 2008 年 10 月 14 日 題意:給一個 7 個 column.
:Problem E.Stone Game ★★★☆☆ 題組: Problem Set Archive with Online Judge 題號: 10165: Problem E.Stone Game 解題者:李濟宇 解題日期: 2006 年 3 月 26 日 題意: Jack 與 Jim.
結構學 ( 一 ) 第八次作業 97/05/22. 題目一 題目一 (a) 先決定放鬆哪個束制,成為靜定結構 以支承 C 之水平反力為贅力,則 C 點滾支 承變成自由端,即形成靜定基元結構 C 點滿足變位諧和  Δ CH =0.
1 Introduction to Java Programming Lecture 3 Mathematical Operators Spring 2009.
第 1 章 PC 的基本構造. 本章提要 PC 系統簡介 80x86 系列 CPU 及其暫存器群 記憶體: Memory 80x86 的分節式記憶體管理 80x86 的 I/O 結構 學習組合語言的基本工具.
: How many 0's? ★★★☆☆ 題組: Problem Set Archive with Online Judge 題號: 11038: How many 0’s? 解題者:楊鵬宇 解題日期: 2007 年 5 月 15 日 題意:寫下題目給的 m 與 n(m
McGraw-Hill/Irwin © 2003 The McGraw-Hill Companies, Inc.,All Rights Reserved. 肆 資料分析與表達.
1 MATLAB 基礎. 2 MATLAB  Workspace: environment (address space) where all variables reside  After carrying out a calculation, MATLAB assigns the result.
MATLAB– MATRIX 專論 ME Fall (week06- Oct27) 原始檔案 : NTU- 初探 MATLAB2(A++)-for-Week0506.ppt.
Basics of MATLAB By DR. Wafaa Shabana
Presentation transcript:

MATLAB

What is MATLAB? MATLAB is a simple programming language with its own extensive library of mathematical and graphical subroutines It integrates computation and graphics in one easy to use interface MATLAB stands for MATrix LABoratory.

What is MATLAB? MATLAB is an interpreted language  It is not a compiled language Matlab is basically a high level language MATLAB is very extendable. There are many add-ons (toolboxes) for specific requirements

What is MATLAB? Main Features  Simple programming rules  Extended accuracy  Comprehensive mathematical library  Excellent matrix computing  Extensive graphics tools  Linkages with other languages  Transportability across environment MATLAB scripts will work on PC, UNIX, Mac

Starting MATLAB Using Citrix

Starting MATLAB Once MATLAB is running the GUI (Graphical User Interface) will appear  Default Window apperance

Starting MATLAB Command Window  Main window in MATLAB  MATLAB displays >> prompt when ready for a command

Variables No need for types. i.e., All variables are created with double precision unless specified and they are matrices. After these statements, the variables are 1x1 matrices with double precision int a; double b; float c; Example: >>x=5; >>x1=2;

Variables Variable names must start with a letter  You’ll get an error if this doesn’t happen  After that, can be any combination of letters, numbers and underscores

Variables Don’t name your variables the same as functions  min, max, sqrt, cos, sin, tan, mean, median, etc  Funny things happen when you do this MATLAB reserved words don’t work either  i, j, eps, nargin, end, pi, date, etc  i, j are reserved as complex numbers initially Will work as counters in my experience so they can be redefined as real numbers

Interactive Commands Enter commands at >> prompt Variable ‘x’ automatically allocated  MATLAB does not require declaration of variables  Nice, but can get you in trouble so be careful

Interactive Commands MATLAB is case sensitive  Variable ‘ans’ will take value of result of command if no equal sign specified Holds most recent result only  Semicolon at end of line will suppress output, it is not required like in C Useful in script files and debugging

Interactive Commands Format of output  Defaults to 4 decimal places  Can change using format statement  format long changes output to 15 decimal places

Operators Scalar arithmetic operations OperationMATLAB form  Exponentiation: ^ a b a^b  Multiplication: *ab a*b  Right Division: / a / b = a/ba/b  Left Division: \ a \ b = b/aa\b  Addition: +a + ba+b  Subtraction: -a – ba-b MATLAB will ignore white space between variables and operators

Order of Operations Parentheses Exponentiation Multiplication and division have equal precedence Addition and subtraction have equal precedence Evaluation occurs from left to right When in doubt, use parentheses  MATLAB will help match parentheses for you

Logical Operators

MATLAB Help Ways to get help in MATLAB  help function name  Provides basic text output Type helpwin on command line

Arrays MATLAB is adept at handling arrays  Optimized for vector/matrix operations  This allows for a reduction of code in some cases Array types: Numeric, character, logical, cell, structure, function handle  Numeric types: single, double, int8, int16, int32, uint8, uint16, uint32

Numeric Arrays One dimensional arrays, called vectors  Can create row or column vectors  Row vector A few ways to create a row vector Or use “:”

Numeric Arrays Column vectors  A few ways to generate column vectors too  Semicolon between elements starts new row  Transpose a row vector, or use return between elements

Numeric Arrays Two-dimensional arrays, called a matrix in MATLAB often Size = rows by columns  [r c] = size(array_name) if array_name is a matrix  size will work for n-dimension arrays and output size of each dimension into a row vector Basic matrix creation:

Numeric Arrays Array addressing  Vector: foo foo(:) gives all row or column elements foo(1:5) gives the first five row or column elements foo(2) gives the second element  Matrix: bar bar(1,3) gives the first row, third column element Bar(:,2) gives all elements in the second column Bar(1,:) gives all elements in the first row Bar(3:4,1:3) gives all elements in the third and fourth rows that are in the first through third columns

矩陣的各種處理 MATLAB 亦可取出向量中的一個元素或一部份來做運 算,例如: >> t(3) = 2 % 將向量 t 的第三個元素更改為 2 t = >> t(6) = 10% 在向量 t 加入第六個元素,其值為 10 t = >> t(4) = [] % 將向量 t 的第四個元素刪除, [] 代表空集合 t =

建立大小為 m×n 的矩陣 在每一橫列結尾加上分號( ; ),例如: >> A = [ ; ; ]; % 建立 3×4 的矩陣 A >> A % 顯示矩陣 A 的內容 A =

mxn 矩陣的各種處理 (I) >> A(2,3) = 5 % 將矩陣 A 第二列、第三行的元素值,改變為 5 A = >> B = A(2,1:3) % 取出矩陣 A 的第二橫列、第一至第三直行,並 儲存成矩陣 B B = 5 6 5

mxn 矩陣的各種處理 (II) >> A = [A B'] % 將矩陣 B 轉置後、再以行向量併入矩陣 A A = >> A(:, 2) = [] % 刪除矩陣 A 第二行(:代表所有橫列, [] 代表空矩陣) A =

mxn 矩陣的各種處理 (III) >> A = [A; ] % 在原矩陣 A 中,加入第四列 A = >> A([1 4], :) = [] % 刪除第一、四列(:代表所有直行, [] 是空矩陣) A =

2-3 常用數學函數 MATLAB 是一個科學計算軟體,因此可以支 援很多常用到的數學函數  >> y = abs(x) % 取 x 的絕對值  >> y = sin(x) % 取 x 的正弦值  >> y = exp(x) % 自然指數 exp(x)  >> y = log(x) % 自然對數 ln(x) MATLAB 也支援複數運算,通常以 i 或 j 代表 單位虛數

向量矩陣的運算 有一些函數是特別針對向量而設計  >> y = min(x) % 向量 x 的極小值  >> y = max(x) % 向量 x 的極大值  >> y = mean(x)% 向量 x 的平均值  >> y = sum(x) % 向量 x 的總和  >> y = sort(x) % 向量 x 的排序

Matrix Index The matrix indices begin from 1 (not 0 (as in C)) The matrix indices must be positive integer Given: A(-2), A(0) Error: ??? Subscript indices must either be real positive integers or logicals. A(4,2) Error: ??? Index exceeds matrix dimensions.

Numeric Arrays Array operations  MATLAB has array or element by element and matrix operations when dealing with arrays Element-by-element operations  Multiplying a vector or array by a scalar is an easy example