---
# System prepended metadata

title: MATLAB Notes
tags: [MATLAB]

---

MATLAB Notes
===

* [name=Ander Liu]

###### tags: `MATLAB`

[TOC]

:::danger
善用 help！！！ Ex: help mean
:::

## Language Fundamentals
### Entering Commands
* **clc** : **cl**ear **c**ommand window

### Matrices and Arrays
* **x = j:k** : [j, j+1, ..., k]
* **x = j:i:k** : [j, j+i, ..., k]
* **zeros** : zeros array
    * **zeros(M,N)**

### Operators and Elementary Operations
#### Arithmetic
* **.***
* **./**

### Data Types
#### Numeric Types
* **eps**
* **inf**

## Mathematics
### Elementary Math
#### Trigonometry
* **sin(X)**
* **cos(X)**

### Exponents and Logarithms
* **exp(X)**

### Complex Numbers
* **abs(X)**
* **imag(Z)**
* **real(Z)**

## Graphics
### 2-D and 3-D Plots
#### Line Plots
* **loglog()** : log-log scale plot
* **plot(X,Y)** : linear plot
* **plot3(x,y,z)** : plot lines and points in 3-D space
* **semilogx()** : semi-log scale plot
* **semilogy()** : semi-log scale plot
* **'+'** : plus sign
* **'o'** : circle
* **'*'** : asterisk(星號)
* **'.'** : point
* **'x'** : cross
* **'square' or 's'** : square
* **'diamond' or 'd'** : diamond
* **'^'** : upward-pointing triangle
* **'v'** : downward-pointing triangle
* **'>'** : right-pointing triangle
* **'<'** : left-pointing triangle
* **'pentagram' or 'p'** : five-pointed star (pentagram)
* **'hexagram' or 'h'** : six-pointed star (hexagram)
* **'r'** : red
* **'g'** : green
* **'b'** : blue
* **'c'** : cyan(青)
* **'m'** : magenta(洋紅)
* **'y'** : yellow
* **'k'** : black
* **'w'** : white

#### Discrete Data Plots
* **stem(X,Y)** : discrete sequence or "stem" plot


### Formatting and Annotation
#### Titles and Labels
* **legend(label1,...,labelN)** : (圖例)
* **title('text')** : graph title
* **xlabel('text')** : X-axis label
* **ylabel('text')** : Y-axis label
* **zlabel('text')** : Z-axis label

#### Axes Appearance
* **axis()** : control axis scaling and appearance
    * **axis([XMIN XMAX YMIN YMAX])**
* **figure()** : create figure window
    * **figure(n)**
* **hold** : hold current graph
    * **hold on**
* **subplot()** : create axes in tiled(鋪) positions
    * **subplot(m,n,p)**
    * **subplot(mnp)**

### Graphics Objects
#### Graphics Object Programming
* **close** : close figure
    * **close all** : closes all the open figure windows

## Data Import and Analysis
### Data Import and Export
#### Workspace Variables and MAT-Files
* **clear** : clear variables and functions from memory

## Others
* **heaviside(X)** : step function
* **phase(G)** : computes the phase of a complex vector
* **rectpuls(T,W)** : sampled aperiodic rectangle generator

## Homepage
* [Homepage](/@NDR/Homepage)