freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

[工學(xué)]第一講-matlab入門(mén)簡(jiǎn)介-在線(xiàn)瀏覽

2024-11-30 14:18本頁(yè)面
  

【正文】 me Size Bytes Class A 2x4 64 double array B 4x2 64 double array ans 1x1 8 double array x 1x1 8 double array y 1x1 8 double array z 1x1 8 double array Grand total is 20 elements using 160 bytes 使用 clear可以刪除工作空間的變數(shù): clear A A ??? Undefined function or variable 39。. 另外 MATLAB有些永久常數(shù)( Permanent constants), 雖然在工作空間中看不 到,但使用者可直接取用,例如: pi ans = 下表即為 MATLAB 常用到的永久常數(shù)。因此,若無(wú)意外情況,運(yùn)算式執(zhí)行的次數(shù)會(huì)等于矩陣的行數(shù)。 % x是一個(gè) 16的零矩陣 for i = 1:6, x(i) = 1/i。 我們可用分?jǐn)?shù)來(lái)顯示此數(shù)列: format rat % 使用分?jǐn)?shù)來(lái)表示數(shù)值 disp(x) 1 1/2 1/3 1/4 1/5 1/6 for 圈可以是多層的,下例產(chǎn)生一個(gè) 16的Hilbert矩陣 h, 其中為于第 i列、第 j行的元素為: h = zeros(6)。 end end disp(h) 1 1/2 1/3 1/4 1/5 1/6 1/2 1/3 1/4 1/5 1/6 1/7 1/3 1/4 1/5 1/6 1/7 1/8 1/4 1/5 1/6 1/7 1/8 1/9 1/5 1/6 1/7 1/8 1/9 1/10 1/6 1/7 1/8 1 /9 1/10 1/11 小提示:預(yù)先配置矩陣 在上面的例子,我們使用 zeros 來(lái)預(yù)先配置( Allocate )了一個(gè)適當(dāng)大小的矩陣。所以在使用一個(gè)矩陣時(shí),若能在事前知道其大小,則最好先使用 zeros 或 ones 等命令來(lái)預(yù)先配置所需的記憶體(即矩陣)大小。 % 印出每一行的平方和 end 1299/871 282/551 650/2343 524/2933 559/4431 831/8801 在上例中,每一次 i的值就是矩陣 h的一行,所以寫(xiě)出來(lái)的命令特別簡(jiǎn)潔。例如先前產(chǎn)生調(diào)和數(shù)列的例子,我們可用 while圈改寫(xiě)如下 : x = zeros(1,6)。 while i = 6, x(i) = 1/i。 end format short ? 邏輯命令 最簡(jiǎn)單的邏輯命令是 if, ..., end, 其基本形式為: if 條件式; 運(yùn)算式; end if rand(1,1) , disp(39。)。此種包含 MATLAB命令的檔案都以 m為副檔名,因此通稱(chēng) M檔案( Mfiles)。Start of !\n39。 for i = 1:3, fprintf(39。, i, i^3)。End of !\n39。 test % 執(zhí)行 Start of ! i = 1 i^3 = 1 i = 2 i^3 = 8 i = 3 i^3 = 27 End of ! 小提示:第一注解行( H1 help line ) 的前兩行是注解,可以使程序易于了解與管理。舉例來(lái)說(shuō), 的第一注解行包含 test 這個(gè)字,因此如果鍵入 lookfor test , MATLAB 即可列出所有在第一注解行包含 test 的 M 檔案,因而 也會(huì)被列名在內(nèi)。 前述的,其效用和將命令逐一輸入完全一樣,因此若在命令集可以直接使用工作空間的變數(shù),而且在命令集中設(shè)定的變數(shù),也都在工作空間中看得到。 舉例來(lái)說(shuō),若要計(jì)算一個(gè)正整數(shù)的階乘( Factorial), 我們可以寫(xiě)一個(gè)如下的 MATLAB函數(shù)并將之存檔于 : function output = fact(n) % FACT Calculate factorial of a given positive integer. output = 1。 end 其中 fact是函數(shù)名, n是輸入引數(shù), output是輸出引數(shù),而 i則是此函數(shù)用到的暫時(shí)變數(shù)。)在執(zhí)行 fact(5)時(shí),MATLAB會(huì)跳入一個(gè)下層的暫時(shí)工作空間( Temperary workspace), 將變數(shù) n的值設(shè)定為 5,然后進(jìn)行各項(xiàng)函數(shù)的內(nèi)部運(yùn)算,所有內(nèi)部運(yùn)算所產(chǎn)生的變數(shù)(包含輸入引數(shù) n、 暫時(shí)變數(shù) i, 以及輸出引數(shù) output) 都存在此暫時(shí)工作空間中。換句話(huà)說(shuō),在呼叫函數(shù)時(shí),你只能經(jīng)由輸入引數(shù)來(lái)控制函數(shù)的輸入,經(jīng)由輸出引數(shù)來(lái)得到函數(shù)的輸出,但所有的暫時(shí)變數(shù)都會(huì)隨著函數(shù)的結(jié)束而消失,你并無(wú)法得到它們的值。若實(shí)際要計(jì)算一個(gè)正整數(shù) n 的階乘(即 n! )時(shí),可直接寫(xiě)成 prod(1:n) ,或是直接呼叫g(shù)amma 函數(shù): gamma(n 1) 。舉例來(lái)說(shuō), n! = n*(n1)!, 因此 function output = fact(n) % FACT Calculate factorial of a given positive integer recursively. if n == 1, % Terminating condition output = 1。 end output = n*fact(n1)。以上例而言, n==1即滿(mǎn)足結(jié)束條件,此時(shí)我們直接將 output設(shè)為 1,而不再呼叫此函數(shù)本身。 如果不先進(jìn)入這個(gè)目錄, MATLAB就找不到你要執(zhí)行的 M檔案。要檢視 MATLAB的搜尋路徑,鍵入path即可: path MATLABPATH d:\matlab5\toolbox\matlab\general d:\matlab5\toolbox\matlab\ops d:\matlab5\toolbox\matlab\lang d:\matlab5\toolbox\matlab\elmat d:\matlab5\toolbox\matlab\elfun d:\matlab5\toolbox\matlab\specfun d:\matlab5\toolbox\matlab\matfun d:\matlab5\toolbox\matlab\datafun d:\matlab5\toolbox\matlab\polyfun d:\matlab5\toolbox\matlab\funfun d:\matlab5\toolbox\matlab\sparfun d:\matlab5\toolbox\matlab\graph2d d:\matlab5\toolbox\matlab\graph3d d:\matlab5\toolbox\matlab\specgraph d:\matlab5\toolbox\matlab\graphics d:\matlab5\toolbox\matlab\uitools d:\matlab5\toolbox\matlab\strfun d:\matlab5\toolbox\matlab\iofun d:\matlab5\toolbox\matlab\timefun d:\matlab5\toolbox\matlab\datatypes d:\matlab5\toolbox\matlab\dde d:\matlab5\toolbox\matlab\demos d:\matlab5\toolbox\tour d:\matlab5\toolbox\simulink\simulink d:\matlab5\toolbox\simulink\blocks d:\matlab5\toolbox\simulink\simdemos d:\matlab5\toolbox\simulink\dee d:\matlab5\toolbox\local 此搜尋路徑會(huì)依已安裝的工具箱( Toolboxes)不同而有所不同。c:\data\mlbook39。 此時(shí) d:\mlbook已加入 MATLAB搜尋路徑(鍵入 path試看看),因此 MATLAB已經(jīng) 看 得到: which test c:\data\mlbook\ 現(xiàn)在我們就可以直接鍵入 test, 而不必先進(jìn)入 。有兩種方法,可以使 MATLAB 啟動(dòng)后,即可載入使用者定義的搜尋路徑 : 1. MATLAB 的預(yù)設(shè)搜尋路徑是定義在 (在 c: \ matlab 之下,或是其它安裝
點(diǎn)擊復(fù)制文檔內(nèi)容
教學(xué)課件相關(guān)推薦
文庫(kù)吧 www.dybbs8.com
備案圖鄂ICP備17016276號(hào)-1