How to find out the problem for "Array indices must be positive integers or logical values"

Hello, guys. My question is the topic. I know it might be a Matlab question but it error occurs in cvx, which is shown as
I wonder if I met this kind of question, how to go to the cvx codes file to check which paramters or settings are wrong? The error comes from this Github program and equations are from line 337 to 356. The equations have been proved in the same name paper, they are approximated into a convex form. Since the UL file in the same page can work successfully and the answer, it seems the problem only comes from the Y and Z variable settings?
Just teach me how to check the problem based on the errors shown in command window please. I will find the problem by myself. Thank you!
(Although I emailed author, it seems that he might forget the email for his github account…

Perhaps something like this is happening:

variable x(2)
Error using indexing
Array indices must be positive integers or logical values.


Error using indexing
Array indices must be positive integers or logical values.

CVX is being run in a loop. Perhaps on some iteration, one of the things which gets into an array index is not a positive integer. Variable values after cvx_end will be NaN if the optimization failed, such as due to infeasible, unbounded, or solver experiencing numerical trouble. If you want to see what’ going on don’t use the quiet mode, and examine any output from one iteration which is used in the next iteration.

If this is happening, its occurrence or not might depend on which solver is used (the program has cvx_solver sedumi), and the versions of everything, as well as the particular input data. And that includes any differences in random numbers drawn in the program. If the random number algorithm or random number seed are changed, the inputs will be different, and the observed behavior might change. If you run the whole program again without resetting the random number seed, you will get different random numbers, and therefore a different problem instance.

Hello Mark, thank you for your help. Sry I caught fever the past days so didnot reply you.
I used your suggest to remove the “cvx_quiet” commands, however, the program still only shows the above errors and stops, which I can not check anything of the results.
And another newly come problem is, I found that if I ignore the error and keep clicking RUN, sometimes the program would not go error and continue processing and then give the answer.

I have no idea why this happens. I know there’re some random generators in the codes, but they only influence the value of the matrix X, Y and Z, not the indeces. And in the program, indeces are just “the number of users” and “antenna”, which both of them are integer numbers, not zero and not negative.

I see the error is only occurring at cvx_end. Maybe there is a screwed up CVX installation. Are you using CVX 3.0beta? Do not use it, because it is riddled with bugs, which will never be fixed. If you are using it, remove all CVX directories from the MATLAB path and install CVX 2.2 in a new MATLAB session.

cvx_version shows the version of CVX.

If you are already using CVX 2.2, try a new MATLAB session. If that doesn’t work, try rebooting your computer.

1 Like

Thank you Mark. Yes I am using the 3.0b version. I’ll try again the codes after I reinstall the version you recommend.

1 Like

Thank you so much! The copied code form Github can work correctly now.