Change in linprog.m output?

4 visualizaciones (últimos 30 días)
Joel Miller
Joel Miller el 13 de Ag. de 2018
Editada: Matt J el 14 de Ag. de 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?

Respuesta aceptada

Matt J
Matt J el 13 de Ag. de 2018
Editada: Matt J el 13 de Ag. de 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 comentarios
Joel Miller
Joel Miller el 14 de Ag. de 2018
Same here, and iters = 0.
Matt J
Matt J el 14 de Ag. de 2018
Editada: Matt J el 14 de Ag. de 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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Logical en Help Center y File Exchange.

Productos


Versión

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by