台湾国立大学郭彦甫Matlab教程笔记(2)
log函數,就是 natural log
log10(x) common logarithm 以10為底的
log2(X) 是以2為底的。
elementary math functions基本數學函數
1.arithmetic 加減乘除
2.trigonometry 三角函數
3.exponents and logarithms 指數和對數函數
4.complex numbers 復數
5.cartesian coordinate system conversion
embedding functions 嵌套函數
1.functions may be embedded into other functions
sin(cos(pi))等價于ans=cos(pi),sin(ans)這種兩階段的形式
2.many lines of code can be condensed into one single command
variables變數
1.variables do not need to be declared before assignment
2.a single “equal” is the assignment operator:指定
10=A是錯的,不能指定,A=10可以 ,是把10指定給A
question:
1.upper case/lower case make difference? diffirent
1.
can variable names can begin with a number ? no for example 2A is illegal
numeric variable type變數類型
默認是double
怎么查看變量類型,可以在command window 輸入 who
會顯示存在的變量名稱
輸入 whos 會出現更多信息:變量名,大小,數據類型,
special variables and constants特殊的變數和常量
some keyword 關鍵字 不能用
比如 inf 表示無限大,eps這個數很小,NaN :not a number 不是一個數,pi表示Π
例如輸出x=1/0,結果會顯示是inf,無限大
例如,輸入y=inf/inf 結果顯示 y不是一個數nan
【如何判斷是否是keyword?]
輸入命令 iskeyword,會出現很多keyword關鍵字
matlab calling priority matlab調用優先級
優先順序舉例子
如下圖現在的cos就不是cos函數,而是一個變數,字符串類型。cos(8)得到的是這個字符串的第八個位置的東西,就是r
本來cos是一個function,這里被當作了 varible,而且發現 varible的優先級比build-in function高
同時告訴我們,不要用function name 或者是 Keyword當作 varible name
下面有一個問題:
【如何把一個變數從 workspace消除?】
解決clear 變數名比如, clear cos,就是把上面定義的cos這個變數消除
clear 不加東西, 整個 workspace 全部清掉
numeric display format 數據顯示格式指令
format
例如 format long 顯示的更長
bank 有兩個小數位
rat 轉成有理數,分數
在加 format rat之前,分數是這樣的顯示:4位小數
加 format rat之后:可以顯示分數的形式
練習:calculate ,using different format to choose the right answer, format ratio and format long
下面的自己的練習
可以看到是選擇d
選擇分數顯示的話
結果選1
【總結一下】
1.elementary math functions基本數學函數
2.embedding functions 嵌套函數
3.variables變數
4.numeric variable type變數類型
5.special variables and constants特殊的變數和常量
6.matlab calling priority matlab調用優先級
7.numeric display format 數據顯示格式
總結
以上是生活随笔為你收集整理的台湾国立大学郭彦甫Matlab教程笔记(2)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: opencv鼠标操作,画矩形
- 下一篇: 台湾国立大学郭彦甫Matlab教程笔记(