fminsearch ''index exceeds matrix dimensions''

1 view (last 30 days)
I am trying to find an optimal fit to my impedance spectroscopy measurement data using fminsearch
When I am running the code I am getting the following error
??? Index exceeds matrix dimensions.
Error in ==> @(x)myfun1(x,omega_s,Z_60(start:stop),Rinit)
Error in ==> fminsearch at 205 fv(:,1) = funfcn(x,varargin{:});
Error in ==> SOH31_Script_V4 at 152 [Y ERR] = fminsearch(@(x) myfun1(x,omega_s,Z_60(start:stop),Rinit),X0,options)
I think the error is due to the start and stop value I am using. I have the measurement of impedances (real, imaginary and the frequencies) for a large range of frequencies (10 mHz to 50kHz)
myfun1 is the error function I am minimizing
I am trying to fit this data to a model. I don't want the optimization problem to run for all frequencies so i want to restrict the start stop to a mid frequency range.
How can I select start and stop?
All the real, imaginary and frequencies are of size 68X1 double
Thanks!

Accepted Answer

Matt J
Matt J on 18 Mar 2014
"stop" must be selected to be no greater than length(Z_60)
  4 Comments
Matt J
Matt J on 18 Mar 2014
OK, well I'm glad the problem is solved.
Avnish
Avnish on 18 Mar 2014
Edited: Matt J on 18 Mar 2014
Matt : For Start I did like this
%Select frequency range
[tmp start]=min(real(Z_60)); %Point at minimum real part (Its a nyquist plot, Imaginary vs real)
start=max(1,start-8); %I ignored first 8 points of high frequency region in the optimization
What do I do with stop? using stop = length(Z_60) gives strange results

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!