Effacer les filtres
Effacer les filtres

how to store a changing variable matrix with the same name

1 vue (au cours des 30 derniers jours)
Bou
Bou le 19 Fév 2014
Commenté : Jos (10584) le 19 Fév 2014
Hello,
I have a row (1x8) of variables named Pars. The variables of Pars are changed by a function (fminsearch). I want to save Pars into another matrix each time one of the variables is changed. I've tried to use an output-function within fminsearch but this doesnt work.
However, within my minimization function (the function that fminsearch tries to minimize) I can write display(Pars) and the variables of Pars are displayed each time one of them is changed. I want to store the displayed variables in a matrix so each time one of the variables is changed they are stored in a new row.
I've tried something like this (this was recommended by someone) but it doesnt work. I also want to save the data to the workspace.
data(1:length(Pars), and+1)=Pars
Can anyone help me? Thanks in advance!
greetings Boudewijn

Réponses (1)

Jos (10584)
Jos (10584) le 19 Fév 2014
Something like this?
data = nan(0,8)
pars = fminsearch(...)
if IsChanged(pars),
data(end+1,:) = pars ;
end
IsChanged is a function (or expression) that you have to define yourself.
  1 commentaire
Jos (10584)
Jos (10584) le 19 Fév 2014
btw your pars is a row vector with 8 columns, but your expression " data(1:length(Pars), end+1)=Pars " suggests that you want to store it as the last column. This does not add up ...

Connectez-vous pour commenter.

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by