MATLAB: Cfit object in function handle

curve fittingfunctionsMATLAB

I have constructed a curve fit "func" with the following line.
Now I want to use "func" inside an anonymous function as e.g
func2= @ (x,c) x-(c*x+x^2)/func(x)
Then I want to find the root of func2=0 using e.g FZERO as
func3=@ (x) func2(x,c)
Could it be causing any trouble that i am using a cfit object inside the function "func2" ? My solution output is making me suspicious. Note that func2 is not the actual function i'm using but of a similar form.
Any help is much appreciated!
Best regards

Best Answer

  • My blind guess is that x or c is a vector in which case,
    func2= @ (x,c) x-(c.*x+x.^2)./func(x)
    % ^ ^ ^