How to solve: Attempted to access inc(:,1); index out of bounds because size(inc)=[0,0]?
Show older comments
I am trying to model a BLP model in MATLAB. For this, I need to compute a non-linear part of utility, which is done via the function below. The problem I encounter is that the error above keeps coming up, whereas the matrix inc is 2301 x 50. Other inputs are the following dimensions, in case that helps: v = 2301 x 200 (namely, because X contains 4 characteristics, and thus we need 4 v's per observation), K = 4, n = 2301, X = 2301 x 4, price1=2301 x 1. I hope you will be able to help me. Thank you very much in advance.
function f = mufunc(X, sigma)
%This function computes the non-linear part of the utility
%This is based on the code written by Aviv Nevo, 1998
global nsm v inc price1 mu
[n K] = size(X);
for i = 1:nsm
v_i = v(:,i:nsm:K*nsm);
inc_i = inc(:,i);
mu(:,i) = (-sigma(1).*price1./inc_i+(X.*v_i*(sigma(2:end))'));
end
f = mu;
Accepted Answer
More Answers (0)
Categories
Find more on Parallel Computing 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!