Error creating a new type of fit using fittype. Expression "____" is not a valid MATLAB expression, has non-scalar coefficients, or cannot be evaluated

This is what I have:
myfittype=fittype('a*exp(b*x)cos(c*x)',...
'dependent',{'y'},'independent',{'x'},...
'coefficients',{'a','b','c'})
f2=fit(xo,Vox,myfittype)
figure
plot(f2,xo,Vox)
This is the error I get:
Error using fittype/testCustomModelEvaluation
(line 12)
Expression a.*exp(b.*x)cos(c.*x) is not a valid
MATLAB expression, has non-scalar coefficients,
or cannot be evaluated:
Error in fittype expression ==>
a.*exp(b.*x)cos(c.*x)
??? Error: Unexpected MATLAB expression.
Error in fittype>iCreateFittype (line 371)
testCustomModelEvaluation( obj );
Error in fittype (line 328)
obj = iCreateFittype( obj,
varargin{:} );
Error in VelocidadE2P2 (line 58)
myfittype=fittype('a.*exp(b.*x)cos(c.*x)',...
Caused by:
Error using fittype/evaluate (line 102)
Error in fittype expression ==>
a.*exp(b.*x)cos(c.*x)
??? Error: Unexpected MATLAB expression.
Does anyone know? Please help

 Accepted Answer

a*exp(b*x)cos(c*x)
has no operation between (b*x) and cos(c*x)
MATLAB does not have implicit multiplication.

More Answers (0)

Categories

Find more on Frequently-used Algorithms in Help Center and File Exchange

Products

Release

R2016a

Community Treasure Hunt

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

Start Hunting!