What is the most compact way to update an index vector out of a cube?
Informazioni
Questa domanda è chiusa. Riaprila per modificarla o per rispondere.
Mostra commenti meno recenti
I have 3 vectors each with n elements (n individuals).
Two of them are exogenous state vectors y and r, both with n elements, and the third is an an endogenous state vector k, also with n elements.
Then there is a decision cube, D, with dimension (ny,nr,nk).
The elements of the y vector are numbers in the set 1:ny, the elements of the r vector are numbers in the set 1:nr. This is because they are indices of a position inside the D cube.
The same is true of the k vector, it takes values in the set 1:nk.
Vectors y and r evolve through time exogenously (every period there is a new vector coming from outside the problem).
The decision cube D has elements(i,j,m) which are numbers in the set 1:nk, because they define the transition of the endogenous k state.
I want to write something like:
knext = D(y, r, k);
where knext is a vector of indices with numbers in the set 1:nk, and vectors (y,r,k) are index vectors with n elements on the three respective dimensions.
Thank you
Joao Ejarque
Risposte (1)
Roger Stafford
il 5 Ago 2013
knext = D(y+ny*((r-1)+nr*(k-1)));
Questa domanda è chiusa.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!