custom fittype error ??Matrix dimensions must agree
显示 更早的评论
Hi All,
I have a customer function dIdVdei that takes 10 inputs and outputs a value. I'd like to fit a function to that, varying 8 of the inputs for the fit, one of the inputs as an independent variable, and 1 as a fixed problem variable.
I create a custom fittype as so:
independentvars = {'V'};
dependentvars = {'y'};
problemvars = {'T'};
coeffvars = {'omega', 'G', 'Aw', 'uL', 'uM', 'g1', 'g2', 'dIdV0'};
expression = 'dIdVdei( V, T, omega, G, Aw, uL, uM, g1, g2, dIdV0)'; %just call the function
func = fittype(expression, 'coefficients', coeffvars, 'independent', independentvars, 'dependent', dependentvars, 'problem', problemvars);
The dIdVdei code works fine on its own, but when I try to create that fittype I get the error:
Expression dIdVdei( V, T, omega, G, Aw, uL, uM, g1, g2, dIdV0) is not a valid MATLAB expression, has
non-scalar coefficients, or cannot be evaluated:
Error in fittype expression ==> dIdVdei( V, T, omega, G, Aw, uL, uM, g1, g2, dIdV0)
??? Matrix dimensions must agree.
I'm having trouble figuring out what the cause is; note this is before trying to fit anything, its just creating the fittype object. Some of the inputs (omega, G, and Aw) can be vectors, but at this point the code shouldn't even know that so I don't see how that could be the problem.
Any advice is appreciated, thanks!
回答(1 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Linear and Nonlinear Regression 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!