필터 지우기
필터 지우기

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 CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by