fitting data with a function containing a call to a vector

Hello
I am sorry if this sound stupid to you all. I have to fit (X,Y) data to a function F(X,a1,a2,a3,...,Z) defined as a function in .m file. F is function of X, of the parameters a and of a quantity Z which has the dimension of X. Z can be defined as a global variable or passed an input variable in the definition of F. I treied either ways, and both failed as it follows.
If I calculate the equation: YF=F(X,a1,a2,...Z)
the result is correctly calculated. So I reckon F is correctly defined.
Whereas the command: ffun=fittype('F(x,a1,a2,a3,a4,a5,a6,a7)',... 'independent','x',... 'coefficient',{'a1','a2','a3','a4','a5','a6','a7'});
fails as: Expression F(x,a1,a2,a3,a4,a5,a6,a7) is not a valid MATLAB expression, has non-scalar coefficients, or cannot be evaluated:
Error in fittype expression ==> F(x,a1,a2,a3,a4,a5,a6,a7) ??? Error using ==> plus Matrix dimensions must agree.
Apparently this occurs since the fittype command passes some dummy x (a 1x2 vector whose values are 0.3333 and 0.66667) to F which does not have the same dimensions of Z. Then the script crashes as the x and Z dimensions do not agree.
Does anyone have hints on how to solve this issue?
Thank you in advance for the help, s.

Risposte (0)

Categorie

Richiesto:

il 21 Mar 2013

Community Treasure Hunt

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

Start Hunting!

Translated by