Azzera filtri
Azzera filtri

Change in linprog.m output?

1 visualizzazione (ultimi 30 giorni)
Joel Miller
Joel Miller il 13 Ago 2018
Modificato: Matt J il 14 Ago 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?

Risposta accettata

Matt J
Matt J il 13 Ago 2018
Modificato: Matt J il 13 Ago 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 Commenti
Joel Miller
Joel Miller il 14 Ago 2018
Same here, and iters = 0.
Matt J
Matt J il 14 Ago 2018
Modificato: Matt J il 14 Ago 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.

Accedi per commentare.

Più risposte (0)

Prodotti


Release

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by