Error taking inverse of a matrix

3 次查看(过去 30 天)
cdob
cdob 2015-3-20
Hi,
I am receiving the error, "Subscript indices must either be real positive integers or logicals", when I attempt to take the inverse of a matrix. Can somebody please help me? Here is my code:
C = xlsread('OP_data.xlsx'); D = C;
y = log(C(:,3));
D(any(C==0,2),:)=[]; y(any(C==0,2),:)=[];
X = [ones(size(D,1),1),log(D(:,5)),log(D(:,6))];
Beta = inv(X'*X)*(X'*y);
Any help would be greatly appreciated!
  1 个评论
Roger Stafford
Roger Stafford 2015-3-20
Somewhere in your system there may be a variable with the name 'inv', which causes matlab to misinterpret your line "Beta = inv(X'*X)*(X'*y);". Try doing a
whos
to see if 'inv' shows up.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by