필터 지우기
필터 지우기

Problem with Fminsearch function

조회 수: 1 (최근 30일)
jasmine
jasmine 2019년 6월 7일
댓글: Torsten 2019년 6월 12일
% Load the data
idxMiddle = blk.audDiff == 0;
audMiddle = [blk.visDiff(idxMiddle,1) blk.responseMade(idxMiddle)];
audMiddle = audMiddle(~audMiddle(:,2)==0,:);
ccSym = blk.visValues;
tn = arrayfun(@(x) length(audMiddle(audMiddle(:,1)==x,2)==2), ccSym);
meanProb = arrayfun(@(x) mean(audMiddle(audMiddle(:,1)==x,2)==2) , ccSym);
reactionLength = blk.responseTime;
% % Do the fitting
parstart = [3 0.5 0.5 0 0.1]; %Initial parameters
nfits = 10; %Number of iterative fits
minErrors = zeros(nfits,1); %Vector to keep track of errors with each fit
pars = cell(nfits,1); %Cell array to keep track of parameters for each fit
%Loop to fit data 10 times
for i=1:nfits
erHandle = @(pars)(errorFun(pars ,[ccSym'; tn'; meanProb'; reactionLength]));
options = optimset('MaxFunEvals', 1000);
pars{i} = fminsearch(erHandle, parstart, options);
minErrors(i) = errorFun(pars{i}, [ccSym'; tn'; meanProb'; reactionLength]);
end
[L,iBestFit] = min(minErrors);
bestPars = pars{iBestFit};
I have a problem with this program, and I'm receiving these errors when I try to run it:
>> model
Error using vertcat
Dimensions of arrays being concatenated are not consistent.
Error in model>@(pars)(errorFun(pars,[ccSym';tn';meanProb';reactionLength]))
Error in fminsearch (line 200)
fv(:,1) = funfcn(x,varargin{:});
Error in model (line 52)
pars{i} = fminsearch(erHandle, parstart, options);
What would you suggest me to do? Thank you in advance.
  댓글 수: 5
jasmine
jasmine 2019년 6월 12일
Oh, yeah, but I still have the same errors :(
Torsten
Torsten 2019년 6월 12일
What about
erHandle = @(pars)(errorFun(pars ,[ccSym.'; tn.'; meanProb.'; (double(reactionLength)).']));

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by