大家好!
小弟我是matlab的新手,
最近在撰寫程式過程中遇到一點問題,
曾試著先爬文或從相關教學書籍甚至google網站尋找解答,
但一直無法解決,
因此來PO文,希望有好心大大可以幫忙解惑!
其實我主要要求解的程式如下列網址
http://imgur.com/a/mval1
而我的程式碼(M檔案)如下:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [result,minimalvalue,Tvalue] = project20160901RFP(q)
format long g
T = 1:1:10 ;
Cp = 100 ;
Cf = 500 ;
result = zeros(1,length(T)) ;
for i = 1:length(T)
syms y x
result(1,i) = int(( ( Cp + int(fun3(x,q)*q*fun2(x),x,0,y) ) / y ) *
fun1(y,q) * fun5(y),y,0,T(i)) + ( ( Cp + int(fun3(x,q)*q*fun2(x),x,0,T(i)) )
/ T(i) ) * fun1(T(i),q) * fun6(T(i)) + int(( ( Cf +
int(fun3(x,q)*q*fun2(x),x,0,y) ) / y ) * fun6(y) * fun1(y,q) * (1-q) *
fun2(y),y,0,T(i)) ;
end
[minimalvalue, I] = min(result(:)) ;
[order] = ind2sub(size(result), I) ;
Tvalue = T(order) ;
function Fpbary = fun1(y,q)
syms t
Fpbary = exp( (-1) * int((1-q)*fun2(t),t,0,y) ) ;
function rofy = fun2(y)
beta = 2 ;
theta = 5 ;
rofy = (beta/theta)*((y/theta)^(beta-1)) ;
function hofy = fun3(y,q)
syms t
mean = 100 ;
sigma = 20 ;
cinf = 1000 ;
constant = 0.2 ;
delta = ( ( icdf('norm',(cdf('norm',0,mean,sigma) + q),mean,sigma) ) / cinf )
;
hofy = ( ((1/q)*int(t*fun4(t),t,0,delta*cinf)) + constant*y ) ;
function aoft = fun4(t)
mean = 100 ;
sigma = 20 ;
aoft = (1/(sigma*((2*pi)^(1/2))))*exp((-1)*((t-mean)^2)/(2*(sigma^2))) ;
function gofy = fun5(y)
k = 2 ;
lamda = 5 ;
gofy = ( k / (lamda^k) ) * ( y^(k-1) ) * exp(-1 * ( (y/lamda)^k ) ) ;
function Gbarofy = fun6(y)
k = 2 ;
lamda = 5 ;
Gbarofy = exp(-1 * ( (y/lamda)^k ) ) ;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
跑完程式後,會有計算出來的相關數值,也會有下列的訊息:
Warning: Explicit integral could not be found.
我知道這訊息的意思是積分無 close-form solution,但我的問題如下:
1. 這樣的話 matlab所算出來的值是否正確?
(我知道可以徒手再去計算檢驗,但計算式真的不容易徒手去算)
2. 如果所算出來的值正確,那怎會出現上述Waring的訊息?
3. 承2.,如果算出來的值不正確,那我該如何修改此程式碼?
我的程式碼有點冗長,或許不易閱讀,真的很不好意思!
希望有好心的大大願意幫忙解惑,由衷感謝!