【正文】
矩陣部分知識(shí)在符號(hào)計(jì)算知識(shí)后。 2 了解函數(shù)相關(guān)深入知識(shí) 3 學(xué)會(huì) m文件的簡(jiǎn)單調(diào)試步驟 特別聲明 部分班級(jí)剛開始學(xué)線性代數(shù)。 for n=1:82 x=x+ end x== x=0。 第四章 MATLAB的編程基礎(chǔ) 第四章 MATLAB的編程基礎(chǔ) 課間提問 提問 1: 如何設(shè)置 MATLAB初始 路徑為自定義的路徑? 課間提問 提問 2: 精度計(jì)算的問題。 Continue; return; trycatch; ;私有函數(shù);變量的作用域。 end 第四章 MATLAB的編程基礎(chǔ) 一個(gè)實(shí)例: 畫圓。 end 第四章 MATLAB的編程基礎(chǔ) 三、函數(shù)相關(guān)知識(shí) 5 M文件的調(diào)試實(shí)例 調(diào)試: function [y]=funcCanshu(x) if nargin==0 y=0。 第四章 MATLAB的編程基礎(chǔ) 三、函數(shù)相關(guān)知識(shí) 5 函數(shù)的參數(shù)可調(diào)性 function [y]=funcCanshu(x) if nargin==0 y=0。 第四章 MATLAB的編程基礎(chǔ) 三、函數(shù)相關(guān)知識(shí) 5 函數(shù)的參數(shù)可調(diào)性 MATLAB提供了兩對(duì)永久變量: nargin和 varargin:用于檢查被調(diào)用函數(shù)的輸入?yún)?shù)數(shù)目 ,檢查函數(shù)體內(nèi)的被調(diào)用時(shí)的輸入?yún)?shù)的值。, out)。 fprintf(39。After sample: a = %f, b = %f\n39。 out = sample(a, b)。Before sample: a = %f, b = %f\n39。 b = 6。,a,b)。 fprintf(39。 b = a * b。,a,b)。 第四章 MATLAB的編程基礎(chǔ) 三、函數(shù)相關(guān)知識(shí) 4 函數(shù)的參數(shù)傳遞 function out = sample(a, b) fprintf(39。這次復(fù)制是非常重要的,因?yàn)樗馕吨m然函數(shù)修改了輸入?yún)?shù),但它并沒有影響到調(diào)用者的原值。 y=x。 y=x。 (?) y=x。 (?) y=x。 用 global定義全局變量。 第四章 MATLAB的編程基礎(chǔ) 三、函數(shù)相關(guān)知識(shí) 2 私有函數(shù) Private Directories You can create your own private directories simply by creating subdirectories called private using the standard procedures for creating directories or folders on your puter. Do not place these private directories on your path. 第四章 MATLAB的編程基礎(chǔ) 三、函數(shù)相關(guān)知識(shí) 3 變量的作用域 局部變量 :在函數(shù)中使用的變量, 只能在函數(shù)的范圍內(nèi)使用。