[讨论] 如何自设function来画图

楼主: gn00291010 (居恩)   2016-03-15 11:54:52
小弟是matlab的新手
http://imgur.com/XezK2Uy
Wbar是某个值,而W是服从lognormal的随机变量
我在将上面的函数画成图时出现了这样的讯息
Error using integral (line 85)
A and B must be floating point scalars.
Error in ffn (line 3)
f =
integral(intfn,w_bar,Inf,'ArrayValued',true)-(w_bar)*(1-logncdf(w_bar,1,0.042849));
下面则是我的code
第一部分
function f = ffn(w_bar)
intfn = @(w) w.*lognpdf(w,1,0.042849);
f =
integral(intfn,w_bar,Inf,'ArrayValued',true)-(w_bar)*(1-logncdf(w_bar,1,0.042849));
第二部分
function g = gfn(w_bar)
intfn = @(w) w.*lognpdf(w,0,0.042849);
g =
(w_bar)*(1-logncdf(w_bar,0,0.042849))+integral(intfn,0,w_bar)-0.25*logncdf(w_bar,0,0.042849);
第三部分
syms w_bar phi
f(w_bar) = ffn(w_bar);
g(w_bar) = gfn(w_bar);
h(w_bar) =
(diff(f,w_bar)*gfn(w_bar))/(diff(f,w_bar)*gfn(w_bar)-diff(g,w_bar)*ffn(w_bar));
想请教各位我的code出了什么问题,感谢各位了
作者: JamesChen (James)   2016-03-15 12:05:00
A and B must be floating point scalars. <=就积分的某部分要是 scalar 阿

Links booklink

Contact Us: admin [ a t ] ucptt.com