Struct contents reference from a non-struct array object?
이전 댓글 표시
I'm building a function to use as a moment condition for a GMM estimation. The package I intend to use requires a matrix of variables, so I used horzcat() to put together my data vectors. I've made the function using individual data vectors, but I get an error when trying to just call specific columns of my double array. Here's my code and error:
consumption = importdata('consumption_nonres_clean.mat');
leisure = importdata('leisure_nonres_clean.mat');
housing = importdata('housing_nonres_clean.mat');
pollution = importdata('pollution_nonres_clean.mat');
lhprice = importdata('lhprice_nonres_clean.mat');
lwage = importdata('lwage_nonres_clean.mat');
hprice = exp(lhprice);
wage = exp(lwage);
pie=.5;
mu=.5;
gamma=.5;
alpha_H=.5;
alpha_C=.5;
phi=-1;
psi=-1;
zeta=-1;
u = [pie mu gamma alpha_H alpha_C];
x = horzcat(consumption, housing, pollution);
y=hprice;
z=[phi, psi, zeta];
e = ( y(:) - ((u(1).u*(4))./(u(2).*u(5))).*((x(:,2).^(z(3)-1)).*(u(1).*x(:,2).^(z(3))+(1-u(1)).*x(:,3).^(-z(3))))./(x(:,1).^(z(1)-1).*(u(3).*x(:,1).^(z(1))+(1-u(3)).*x(:,3).^(-z(1)))));
Here's the error:
Struct contents reference from a non-struct array object.
Error in Untitled (line 24)
e = ( y(:) -
((u(1).u*(4))./(u(2).*u(5))).*((x(:,2).^(z(3)-1)).*(u(1).*x(:,2).^(z(3))+(1-u(1)).*x(:,3).^(-z(3))))./(x(:,1).^(z(1)-1).*(u(3).*x(:,1).^(z(1))+(1-u(3)).*x(:,3).^(-z(1)))));
I was trying to turn the double into a struct but it didn't seem to help.
채택된 답변
추가 답변 (1개)
PN Reddy
2020년 9월 13일
0 개 추천
Struct contents reference from a non-struct array object.
Error in fun (line 7)
fx=10*(x1-1)^2+20.*x1.x2+(x3-3)^2;
댓글 수: 1
Steven Lord
2020년 9월 13일
20.*x1.x2
You're missing an operator (my guess would be *) before x2.
카테고리
도움말 센터 및 File Exchange에서 MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!