作者chobo (巧宝)
看板MATLAB
标题[绘图] 函数绘图 有参数
时间Tue Nov 1 18:17:35 2016
各位高手 大家好
我想画出一个下列的函数
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://webptt.com/cn.aspx?n=bbs/MATLAB/M.1477995457.A.582.html
1F:推 ksr310135: plot(k) 11/01 23:00
2F:→ chobo: 谢谢回覆,但结果显示Undefined function or variable 'k'. 11/02 19:09
3F:→ nush469: plot(1:N,k) 11/03 00:36
4F:推 warmtake: 你的输出K是甚麽?矩阵还是向量? 11/03 11:38
5F:→ warmtake: 看到了,是行向量。试试看plot(k') 11/03 11:39
6F:→ warmtake: 不过我想你还是先检查输出K吧,因为你的讯息表示你没有K 11/03 11:41
7F:→ chobo: 谢谢回覆。我再试试看 11/04 05:54