MATLAB:Input argument "x" is undefined

问题描述:

MATLAB:Input argument "x" is undefined
程序如下:function F=fun(x)
t=1; % the time,here is one year
std=16000000000; %2011-6-30 short term debt
ltd=1.57538e+12; % long term debt
debt=std+0.5*ltd; % debt value
rf=0.03125 % risk free interest rate
equity=1.0509e+011; %equity value
stdy=0.2045; %yearly volatility
d1=(log(x(1))/debt+(rf+0.5*x(2)^2)*t)/(x(2)*sqrt(t));
d2=d1-x(2)*sqrt(t);
r=exp(-rf*t); % risk free discount rate
nd1=normcdf(d1);
nd2=normcdf(d2);
F=[-stdy+nd1*x(1)*x(2)/equity;x(1)*nd1-debt*r*nd2-equity];
运行之后结果是 Input argument "x" is undefined.
Error in ==> fan at 12
d1=(log(x(1))/debt+(rf+0.5*x(2)^2)*t)/(x(2)*sqrt(t));
1个回答 分类:综合 2014-11-30

问题解答:

我来补答
% 这是一个函数,把它保存为 fun.m 后再调用.
>> x=[1 2];
F=fun(x)
F =
1.0e+11 *
-0.0000
-2.3164 % 没有问题
 
 
展开全文阅读
剩余:2000
上一页:hfftbjhg