필터 지우기
필터 지우기

Using fminsearch : converting mex file to a function

조회 수: 2 (최근 30일)
Dev
Dev 2015년 2월 23일
편집: Dev 2015년 2월 23일
iono_layer_parms = [a, b, -1, -1, -1, -1];
[iono, iono_extra] = iri2012(lat, lon, R12, UT, ht_start, ht_step,num_hts,iono_layer_parms);
ionofreq = 0.008978663597663*sqrt((10.^(-6))*(iono(1,18:end)));
ban = ionofreq(76:126) - D6xc;
[x,fval] = fminsearch(@(x)ban,[10.52, 490]);
This is the code I have written to use fminsearch for my purpose. I have all the variables defined for iri2012 except 'a' and 'b'. I want to change variables 'a' and 'b' only and want to mimize 'ban'. iri2012 is a Matlab wrapper to the IRI-2012 fortan based empirical model ionosphere. The actual programme is a mex wrapper (iri2012_matlab_wrapper.for) to the Fortran code (irisub.for). And when I run this code, I get the following errors :
Subscripted assignment dimension mismatch.
Error in fminsearch (line 191)
fv(:,1) = funfcn(x,varargin{:});
Error in Naldermead (line 25)
[x,fval] = fminsearch(@(x)ban,[10.52, 490]);
I want to take one of the outputs of iri2012 which is iono(1,18:end) .
The code is named Naldermead.m
I think there is more than these errors. The real pronblem may be converting the mex wrapper into a function. Please let me know if I can work on this problem with this approach.
  댓글 수: 6
John D'Errico
John D'Errico 2015년 2월 23일
So if ban is a vector, it is a CONSTANT. You may think of it as a function of a and b, but it is just a constant as you have it here.
You need to write a function that returns the sum of squares of the vector ban, where the function will take a and b as an argument vector of length 2. The function must compute ban internally, then return sum(ban.^2) to minimize.
Dev
Dev 2015년 2월 23일
편집: Dev 2015년 2월 23일
Thank You.

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Solver Outputs and Iterative Display에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by