Struct contents reference from a non-struct array object?
Afficher commentaires plus anciens
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.
Réponse acceptée
Plus de réponses (1)
PN Reddy
le 13 Sep 2020
0 votes
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 commentaire
Steven Lord
le 13 Sep 2020
20.*x1.x2
You're missing an operator (my guess would be *) before x2.
Catégories
En savoir plus sur MATLAB dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!