Effacer les filtres
Effacer les filtres

Change in linprog.m output?

1 vue (au cours des 30 derniers jours)
Joel Miller
Joel Miller le 13 Août 2018
Modifié(e) : Matt J le 14 Août 2018
I use the following code to fit multiple data sets using linprog.m.
for k=1:nsets
b = [data(:,k)+2*noise; -data(:,k)+2*noise];
[fitpars(:,k), ~, flag(k)] = linprog(w,A,b,[],[],lb,ub,[],opts);
end
A solution is not found for each data set, so I save the exitflag. The code executes successfully in R2016b, but in R2018a I get the error message "Unable to perform the assignment because the size on the left side is 320-by-1 and the size on the right side is 0-by-0." whenever the exitflag does not equal 1. (fitpars(:,k) is size 320-by-1) In both R2016b and R2018a I use the default algorithms. Is there a way to get R2018a to provide output compatible with the output from R2016b?

Réponse acceptée

Matt J
Matt J le 13 Août 2018
Modifié(e) : Matt J le 13 Août 2018
You should save to a cell array.
[fitpars{k}, ~, flag(k)] = linprog(w,A,b,[],[],lb,ub,[],opts);
It was just random luck that your original code ever worked. You cannot stick an empty result into the column of a non-empty matrix.
  11 commentaires
Joel Miller
Joel Miller le 14 Août 2018
Same here, and iters = 0.
Matt J
Matt J le 14 Août 2018
Modifié(e) : Matt J le 14 Août 2018
OK, well I think that proves my earlier conjecture. There was never any guarantee, even in R2016b, that the output of linprog will be non-empty, so storing results to a cell array was always the only safe thing to do.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Produits


Version

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by