フィルターのクリア

how to store a changing variable matrix with the same name

1 回表示 (過去 30 日間)
Bou
Bou 2014 年 2 月 19 日
コメント済み: Jos (10584) 2014 年 2 月 19 日
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

回答 (1 件)

Jos (10584)
Jos (10584) 2014 年 2 月 19 日
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 件のコメント
Jos (10584)
Jos (10584) 2014 年 2 月 19 日
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 ...

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by