作者angelina877 (牛牛)
看板MATLAB
標題[心得] 初學funtion 入門問題
時間Sat Jul 12 22:01:04 2014
程式碼
function [x,y]= poler2rect(r,theta)
x=r*cos(theta*pi/180);
y=r*sin(theta*pi/180);
RUN之後
??? Input argument "r" is undefined.
Error in ==> poler2rect at 2
x=r*cos(theta*pi/180);
出現這個bug 可是我不知道怎麼解
感覺 蠻基礎得
麻煩 carry一下小妹QQ
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 118.171.102.18
※ 文章網址: http://www.ptt.cc/bbs/MATLAB/M.1405173666.A.60C.html
推 sin55688:函數定義好之後,你是要呼叫它,而不是執行它。 07/12 23:55
→ sin55688:例如 poler2rect(1,pi)。 它就會回傳對應的x,y值給你 07/12 23:56
推 profyang:另外建議你用r.*cos...... 這樣你r可以不用只輸入單一值 07/13 13:19
→ angelina877:謝謝大家q_q 07/15 00:08