필터 지우기
필터 지우기

How to use a matrix of variables with fminsearch?

조회 수: 4 (최근 30일)
Erick Alejandro
Erick Alejandro 2014년 3월 1일
답변: Walter Roberson 2014년 3월 1일
Hi,
I am trying to fit four experimental curves simultaneously. Each of the four curves is generated from six parameters. The input matrix needs to be a 6x4 matrix, six parameters per column for each of the curves. So when I call fminsearch:
[bestvars, chisquared] = fminsearch(@minimize, parametermatrix, options, ...)
Where ... are other matrices or vectors I need to input for later parts of the program.
It gives the error:
Subscripted assignment dimension mismatch.
Error in fminsearch (line 191) fv(:,1) = funfcn(x,varargin{:});
Error in entropification (line 27) [bestvars, chisquared] = fminsearch(@minimize, parametermatrix, options, ...);
If I use just a vector from parametermatrix, and use these variables for all four curves, instead of six unique parameters for each curve, it works. However, this doesn't give me the unique bestvars for each curve.
My minimization function is a chisquared function. The numbers and 10e-6 in there are just for unit conversions so ignore those:
[mutCpcal, mutCp_folded, mutCp_unfolded] = gencps(parametermatrix, mutt); for i = 1:length(mutt) for j = 1:size(mutt,2) mutCperror(i,j) = ((((mutPstd(i,j).*10^-6.*60)./(conc.*0.0003268))./sqrt(mutN(j,1))))./1000; mutsumchisq(i,j) = (((mutcp(i,j) - mutCpcal(i,j)))./(mutCperror(i,j))).^2; end end chisq = sum(sum(mutsumchisq));
And this returns the scalar value from doubly summing mutsumchisq so it should output the correct format.
With a matrix of variables as the fminsearch input, the program will only go through one iteration before giving me the fminsearch error. It seems that MatLab is not liking having a matrix of variables as the input for varying. Any help is greatly appreciated.

채택된 답변

Walter Roberson
Walter Roberson 2014년 3월 1일
Use a vector of 24 parameters. reshape() the vector inside the function so you can get at the rows or columns.

추가 답변 (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