Can I use fitnlm inside the splitapply command?

조회 수: 3 (최근 30일)
Francisco GarcesVega
Francisco GarcesVega 2016년 7월 25일
답변: Div Tiwari 2016년 8월 8일
Can I use fitnlm inside the splitapply command?, if so can you provide the right syntaxis or command line. I had try several and keep getting error in the line. I have use this form, or the same form setting the anonymous funcction before the splitapply line but get the same error.
yw=splitapply(@fitnlm,DataD.time,DataD.logNN0,@(b,x)-(x/b(1)).^b(2),[2 .7],G)
The data variables must have the same number of rows as the vector of group numbers. The group number vector has 259 row(s), and data variable 3 has 1 row(s).
Thanks

답변 (1개)

Div Tiwari
Div Tiwari 2016년 8월 8일
The 'splitapply' function requires all data input arguments to have the same length as G if the data is a vector, or have their number of rows or columns equal the length of G, depending on the orientation of G. Please use 'repmat' for the function handle and coefficients of the model in order to meet this requirement.
Additionally, if the 'func' input to 'splitapply' returns a nonscalar output argument, the argument must be oriented so that splitapply can concatenate the output arguments from successive calls to 'func'. Since 'fitnlm' returns a NonLinearModel object, you may define an anonymous function to call fitnlm, and then return the estimate from the resulting fitted model object. You can then use its handle as the first input argument to 'splitapply'.

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by