看板 MATLAB 關於我們 聯絡資訊
各位高手 大家好 我想畫出一個下列的函數 function k=myFun(alpha,delta,phi,k0,N) % N = number of iterations (you can make another function % to determine when you want to stop. k = zeros(N,1); for i=1:N if i==1 k(1) = k0; else k(i) = delta*(k(i-1)).^(alpha.*(1-phi)); end end 我的參數設定成 0< alpha,delta,phi<1 但我沒有放進檔案中 我嘗試了 plot(k, k(i)) 結果顯示 Subscript indices must either be real positive integers or logicals. 也嘗試了 ezplot ('k(i)') 結果顯示 Error using inlineeval (line 14) Error in inline expression ==> k(i) Undefined function 'k' for input arguments of type 'double'. 還嘗試了 fplot ('k(i)') 結果顯示 Error using fplot (line 51) Not enough input arguments. 可說是亂槍打鳥 但還是沒辦法畫出初學者的我想要的圖形 只好請求大家的幫忙 謝謝大家 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 176.253.138.164 ※ 文章網址: https://www.ptt.cc/bbs/MATLAB/M.1477995457.A.582.html
ksr310135: plot(k) 11/01 23:00
chobo: 謝謝回覆,但結果顯示Undefined function or variable 'k'. 11/02 19:09
nush469: plot(1:N,k) 11/03 00:36
warmtake: 你的輸出K是甚麼?矩陣還是向量? 11/03 11:38
warmtake: 看到了,是行向量。試試看plot(k') 11/03 11:39
warmtake: 不過我想你還是先檢查輸出K吧,因為你的訊息表示你沒有K 11/03 11:41
chobo: 謝謝回覆。我再試試看 11/04 05:54