fminsearch, Not enough input arguments.
3 ビュー (過去 30 日間)
古いコメントを表示
Below is my code to estimate the parms1 and parms2.
Anyone can give me some helps?
Thanks!
function rresult = calibgrain(DBn_2,dateob,Tb)
dss = linspace(0.01,3,100);
ggf = linspace(0.5,5,100);
rresult = [];
for ii = 1:length(dss)
for jj = 1:length(ggf)
dsnowi = dss(ii);grfactor = ggf(jj);
startparms = [dsnowi grfactor];
%rosen = @RMSE1 RMSE1(startparms);
%fminsearch(@(prms) BER_optimise(prms(1), prms(2)),x0)
bestparms = fminsearch(@(parms) RMSE1(parms), startparms);
%bestparms = fminsearch(@RMSE1,RMSE1(startparms)); %fminsearchbnd(@(x) f(x,c),[0.3;1], [0 0],[5 5])
dsnowi = bestparms(1);
grfactor = bestparms(2);
[dsns_2,lws,btotals,phis,dsnows_y2_r1,tsnows,sds_0,kss,tsss,gds,outmelts,YEH,YEV,YEVH, YEHV,result,compaction,ritisi,stor,ro] = msnow(1,6552,DBn_2,dsnowi,grfactor);
rmsecomp = calcrmse(YEH,dateob,Tb);
rresult = [rresult ;dsnowi grfactor rmsecomp];
end % end of jj loop
end % end of ii loop
function thisrmse = RMSE1(parms)
% nest this function inside calibgrain so that it has
% access to all of calibgrain's variables.
dsnowi = parms(1);
grfactor = parms(2);
[dsns_2,lws,btotals,phis,dsnows_y2_r1,tsnows,sds_0,kss,tsss,gds,outmelts,YEH,YEV,YEVH, YEHV,result,compaction,ritisi,stor,ro] = msnow(1,6552,DBn_2,dsnowi,grfactor);
thisrmse = calcrmse(YEH,dateob,Tb);
end % end of function RMSE1
end % end of function calibgrain
0 件のコメント
回答 (2 件)
Alan Weiss
2020 年 12 月 30 日
Next time please give the entire error message by copying and pasting everything in red:
Not enough input arguments.
Error in calibgrain/RMSE1 (line 30)
[dsns_2,lws,btotals,phis,dsnows_y2_r1,tsnows,sds_0,kss,tsss,gds,outmelts,YEH,YEV,YEVH,
YEHV,result,compaction,ritisi,stor,ro] = msnow(1,6552,DBn_2,dsnowi,grfactor);
Error in calibgrain>@(parms)RMSE1(parms) (line 14)
bestparms = fminsearch(@(parms) RMSE1(parms), startparms);
Error in fminsearch (line 201)
fv(:,1) = funfcn(x,varargin{:});
Error in calibgrain (line 14)
bestparms = fminsearch(@(parms) RMSE1(parms), startparms);
The error is in the msnow function, not in how you are calling fminsearch.
Alan Weiss
MATLAB mathematical toolbox documentation
参考
カテゴリ
Help Center および File Exchange で Symbolic Math Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!