Re: [問題] 自訂function無法成功的問題已回收

看板MATLAB作者 (juzn)時間15年前 (2010/09/26 17:45), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/3 (看更多)
※ 引述《jon7938 (jon)》之銘言: : 根據數值分析課本 Applied Numerical Methods : 3章中提到 M-file & function : -------------------------------------------------------------- : 我先存好一個 money.m : 內容: : p=100000; : i=0.06; : n=[1:7]; : f=p*(1+i).^n : 在command window中 : 輸入 : money : f = : 1.0e+005 * : 1.0600 1.1236 1.1910 1.2625 1.3382 1.4185 1.5036 : 但是想執行 : function f = money(p, i, n); money.m的內容改成如下: function [f] = money(p,i,n) f=p*(1+i).^n; 然後在command window中執行 n=1:7; money(100000,0.06,n); 試試看吧 : 卻出現 : Error: Function definitions are not permitted at the prompt or in scripts. : 無法繼續下去 : 求各位指點 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 114.34.192.204
文章代碼(AID): #1CdnOdrw (MATLAB)
討論串 (同標題文章)
文章代碼(AID): #1CdnOdrw (MATLAB)