Hi I tried to run the following and it keeps giving me the following. Can somebody help me fix it.
Show older comments
close all clear all
%Question # 1D
alpha=1 beta=2 sigma=2 BetaOLS_Vector=ones(1000,2) for i=1:1000 x=normrnd(2,1,[200,1]); e=normrnd(0,sigma,[200,1]); y=alpha + beta*x +e(i); Con=ones(200,1); xn=[Con x]; BetaOLS_Vector(i)= inv(xn'*xn)*xn'*y end
In an assignment A(I) = B, the number of elements in B and I must be the same.
Error in ProblemTwoQuestionOne (line 16) BetaOLS_Vector(i)= inv(xn'*xn)*xn'*y
Accepted Answer
More Answers (1)
Image Analyst
on 19 Sep 2014
0 votes
BetaOLS_Vector(i must be a single number. Evidently inv(xn'*xn)*xn'*y is not a single number. Check the dimensions of xn and y and make sure it works out to a scalar.
1 Comment
Solomon Gofere
on 19 Sep 2014
Categories
Find more on MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!