Index exceeds matrix dimensions Economic Model
Show older comments
Hello everybody, I have a question. Perhaps any of you could be kind enough to help me. It has to do with the firing part of my model:
- f=randperm(length(workforce));
- f=f(1:-vacancies(i));
Now normally what happens you get something like this: (when there are 2 vacancies for i(the firm)):
- f=[3,2,3,4,12];
- f=f(1:--2)
And it returns: [3,2], so that these are both fired. However I am adjusting the model and now I have a situation where it’s possible that: (still when there are 2 vacancies)
- f=[3];
- f=f(1:--2)
And it doesn’t work, because there aren’t 2 to fire. Therefore I get an error: Index exceeds matrix dimensions. Instead I would like the model to fire the one and leave the other vacancy unfulfilled. I have been wrapping my head around this and would appreciate any suggestions!
Thanks in advance!
Accepted Answer
More Answers (0)
Categories
Find more on Matrix Indexing 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!