[討論] 如何自設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