custom fittype error ??Matrix dimensions must agree

1 view (last 30 days)
Darin
Darin on 24 Jul 2014
Answered: Darin on 25 Jul 2014
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!

Answers (1)

Darin
Darin on 25 Jul 2014
Yeah I keep playing with this and the error is boggling.
What does it mean matrix dimensions don't agree? What matrices?
I even made a new version of the code that takes only scalar inputs, since that's what it should need for fit() anyway (although idk how it would detect that at this point in the code), and it still gives the Matrix error, so I guess that's not the source.
Any insight would be wonderful, thank you!

Products

Community Treasure Hunt

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

Start Hunting!