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

正文內(nèi)容

matlab入門教程-在線瀏覽

2024-08-05 22:03本頁面
  

【正文】 constants),雖然在工作空間中看不 到,但使用者可直接取用,例如: pi ans = 下表即為MATLAB常用到的永久常數(shù)。因此,若無意外情況,運算式執(zhí)行的次數(shù)會等於矩陣的行數(shù)。 % x是一個16的零矩陣 for i = 1:6, x(i) = 1/i。我們可用分數(shù)來顯示此數(shù)列: format rat % 使用分數(shù)來表示數(shù)值 disp(x) 1 1/2 1/3 1/4 1/5 1/6 for圈可以是多層的,下例產(chǎn)生一個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來預(yù)先配置(Allocate)了一個適當(dāng)大小的矩陣。所以在使用一個矩陣時,若能在事前知道其大小,則最好先使用zeros或ones等命令來預(yù)先配置所需的記憶體(即矩陣)大小。 % 印出每一行的平方和 end 1299/871 282/551 650/2343 524/2933 559/4431 831/8801 在上例中,每一次i的值就是矩陣h的一行,所以寫出來的命令特別簡潔。例如先前產(chǎn)生調(diào)和數(shù)列的例子,我們可用while圈改寫如下: x = zeros(1,6)。 while i = 6, x(i) = 1/i。 end format short 1邏輯命令 最簡單的邏輯命令是if, ..., end,其基本形式為: if 條件式; 運算式; end if rand (1,1) , disp(39。)。此種包含MATLAB命令的檔案都以m為副檔名,因此通稱M檔案(Mfiles)。Start of !\n39。 for i = 1:3, fprintf(39。, i, i^3)。End of !\n39。 test % Start of ! i = 1 i^3 = 1 i = 2 i^3 = 8 i = 3 i^3 = 27 End of ! 小提示:第一注解行(H1 help line) ,可以使程式易於了解與管理。舉例來說,因此如果鍵入lookfor test,MATLAB即可列出所有在第一注解行包含test的M檔案。其效用和將命令逐一輸入完全一樣,因此若在命令集可以直接使用工作空間的變數(shù),而且在命令集中設(shè)定的變數(shù),也都在工作空間中看得到。舉例來說,若要計算一個正整數(shù)的階乘 (Factorial),: function output = fact(n) % FACT Calculate factorial of a given positive integer. output = 1。 end 其中fact是函數(shù)名,n是輸入引數(shù),output是輸出引數(shù),而i則是此函數(shù)用到的暫時變數(shù)。)在執(zhí)行fact(5)時, MATLAB會跳入一個下層的暫時工作空間(Temperary workspace),將變數(shù)n的值設(shè)定為5,然後進行各項函數(shù)的內(nèi)部運算,所有內(nèi)部運算所產(chǎn)生的變數(shù)(包含輸入引數(shù)n、暫時變數(shù)i,以及輸出引數(shù)output)都存在此暫時工作空間中。換句話說,在呼叫函數(shù)時,你只能經(jīng)由輸入引數(shù)來控制函數(shù)的輸入,經(jīng)由輸出引數(shù)來得到函數(shù)的輸出,但所有的暫時變數(shù)都會隨著函數(shù)的結(jié)束而消失,你并無法得到它們的值。若實際要計算一個正整數(shù)n的階乘(即n!)時,可直接寫成prod(1:n),或是直接呼叫g(shù)amma函數(shù):gamma(n1)。 舉例來說,n! = n*(n1)!,因此前面的階乘函數(shù)可以改成遞式的寫法: 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即滿足結(jié)束條件,此時我們直接將output設(shè)為1,而不再呼叫此函數(shù)本身。如果不先進入這個目錄,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 此搜尋路徑會依已安裝的工具箱(Toolboxes)不同而有所不同。c:\data\mlbook39。 此時d:\mlbook已加入MATLAB搜尋路徑(鍵入path試看看),因此MATLAB已經(jīng)看得到 : which test c:\data\mlbook\ 現(xiàn)在我們就可以直接鍵入test。有兩種方法,可以使MATLAB啟動後 ,即可載入使用者定義的搜尋路徑: (在c:\matlab之下,或是其他安裝MATLAB 的主目錄下),MATLAB每次啟動後,即自動執(zhí)行此檔案。 ,若此檔案存在,則執(zhí)行其所含的命令。 每次MATLAB遇到一個命令(例如test)時,其處置程序為: 。 ,檢查其是否為目前工作目錄下的M檔案。 ,則MATLAB會發(fā)出嗶嗶聲并印出錯誤訊息。 MATLAB儲存變數(shù)的基本命令是save,在不加任何選項(Options)時,save會將變數(shù)以二進制(Binary)的方式儲存至副檔名為mat的檔案,如下述: save:。 save filename x y z :將變數(shù)x、y、。若想看到檔案內(nèi)容,則必須加上ascii選項,詳見下述: save filename x ascii:將變數(shù)x以八位數(shù)存到名為filename的ASCII檔案。 另一個選項是tab,可將同一列相鄰的數(shù)目以定位鍵(Tab)隔開。因此以副檔名mat結(jié)尾的檔案通常是MATLAB的二進位資料檔。 load命令可將檔案載入以取得儲存之變數(shù):
點擊復(fù)制文檔內(nèi)容
環(huán)評公示相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1