Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.



Re: undefined independent variable x
Posted:
May 20, 2013 11:06 AM


"Kam Hoi " <lkhbhjs@hotmail.com> wrote in message news:knd7h7$cq3$1@newscl01ah.mathworks.com... > When i type the followings > function [b, CI, R, Yhat_CI, e]=OSL_robust (X, Y, significance) > b=inv(X'*X)*(X'*Y) > cov=inv(X'*X)*(X'*diag(e^2)*X)*inv(X'*X) > se=(diag(cov))^0.5 > t=b./se > p=2*(1cdf('norm',abs(t),0,1)) > R2c=1(((e'*e)/T)/var(Y,1)) > R2u=1((e'*e)/Y'*Y) > AR2c=1((1/TK1)*e'*e)*(var(Y)) > AR2u=1((1/TK)*e'*e)/((Y'*Y)/T) > CIU=(b+1.96*se) > CIL=(b+1.96*se) > Yhat=Xb > Yhat_CI=[X*CIU,X*CIL] > e=YYhat > > > It comes out that ??? Input argument "X" is undefined.
You ran this code by pressing the green triangle in the Editor or by just typing:
OSL_robust
didn't you? That calls this function with 0 input arguments, so X is indeed undefined when MATLAB tries to execute the second line. Call it with three input arguments, like the functions on this documentation page are being called with input arguments:
http://www.mathworks.com/help/matlab/learn_matlab/callingfunctions.html
BTW, do NOT use inversion to solve the normal equations. Use the backslash operator instead.
http://www.mathworks.com/help/matlab/math/systemsoflinearequations.html http://www.mathworks.com/help/matlab/ref/inv.html
 Steve Lord slord@mathworks.com To contact Technical Support use the Contact Us link on http://www.mathworks.com



