看板 MATLAB 關於我們 聯絡資訊
我在M檔案中輸入以下函數 function y=gx(x) y=2.*x+x.^2; 而執行過後不斷跑出 Not enough input arguments Error in gx(line 2) y=2.*x+x.^2 請問該如何更改才不會跑出Error?? -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 220.143.83.16 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/MATLAB/M.1577294812.A.38C.html
shuncheng: 你直接compile function檔? 12/26 02:38
cos66666: 是阿 因為書上是這樣教的 12/26 09:21
cos66666: 我是在script編譯的 12/26 09:30
shuncheng: 簡單的說 你寫好了這個程式 程式就看得懂這個函數了 12/26 16:12
shuncheng: 因此你要使用這個函數 舉例來說會這樣打 12/26 16:12
shuncheng: x = 3; y = gx(x); 12/26 16:12
shuncheng: 你直接compile function檔 x沒變數宣告 當然會有錯誤 12/26 16:12
sppmg: 應該說你如果是按圖形介面或f5執行(run),相當於在命令列 12/26 22:37
sppmg: 打 gx() 所以沒給足夠參數。 12/26 22:37
cos66666: 感謝2位s大 12/27 14:09