[問題] 一個新手問題已回收

看板MATLAB作者 (秋粟)時間16年前 (2009/05/27 01:45), 編輯推噓2(205)
留言7則, 3人參與, 最新討論串1/1
我是最近才開始用matlab的新手, 想請問一下板上的大大們, 我在.m檔打上 function[result,error]=evaluateroot(a,erroreps) xold=1;absa=abs(a); if(absa<=eps) result=0; error=0; else while(1) xnew=(xold+absa/xold)*0.5; if(abs((xnew-xold)/xnew)<erroreps) break end xold=xnew; end if(a>0) result=xnew; else result=j*xnew; end error=abs((xnew-xold)/xnew); end end 之後按下=> save and run 為什麼不能執行, command window一直出現: ??? Input argument "a" is undefined. Error in ==> hw35 at 2 xold=1;absa=abs(a); 可不可以請大家告訴小弟我一下,謝謝。 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 203.77.79.134

05/27 01:49, , 1F
你這函式需要兩個輸入a,erroreps 你要自己想辦法給
05/27 01:49, 1F

05/27 01:51, , 2F
那是要先在command window裡打a=?erroreps=?嗎?謝謝
05/27 01:51, 2F

05/27 02:06, , 3F
若你能給a,那就在command windows打 [r,e]=evaluateroot(
05/27 02:06, 3F

05/27 02:06, , 4F
你要給定的a,你要給定的erroreps)
05/27 02:06, 4F

05/27 02:06, , 5F
如果a是你要求的,你只知道erroreps,那function命法就是
05/27 02:06, 5F

05/27 02:07, , 6F
function [a,result,error]=evaluateroot(erroreps)
05/27 02:07, 6F

05/27 07:04, , 7F
嗯,感謝^^
05/27 07:04, 7F
文章代碼(AID): #1A72hB2t (MATLAB)
文章代碼(AID): #1A72hB2t (MATLAB)