Error: 'When calling a function, or indexing a variable, use parentheses. Otherwise check for mismatched delimiters.'

7 views (last 30 days)
Hi! I am trying to define a new function type (ft) which I was later use to fit a curve. The code I have written is as follows, and I keep receiving the same error message. Can anyone help?
ft = ( 'b + (a * ((x+k)*(x^-1)) )', 'independent', 'x', 'coefficients', {'a', 'b', 'k'} )
I have tried various different types of the equation, with different parentheses including:
parentheses around the whole equation at start as well as parenthese around full function
and 'b + (a*(x/(x+k)))'
  4 Comments
Dyuman Joshi
Dyuman Joshi on 17 Feb 2023
So you want plot a graph corresponding to a, b and k as constants/coefficients and x as the independent variable?
Cara
Cara on 17 Feb 2023
yes, however the line of code I am looking at is just to define the fittype custom equation.
I would then do f = (x, y, ft, 'StartPoint', 'a0, b0, k0') (a0, b0, k0 are predefined variables)
and then plot (x, y, f, 's')
to generate a graph of the original data with the fit curve according to my predefined equation.

Sign in to comment.

Answers (1)

the cyclist
the cyclist on 17 Feb 2023
Is this what you are trying to do?
ft = fittype( 'b + (a * ((x+k)*(x^-1)) )', 'independent', 'x', 'coefficients', {'a', 'b', 'k'} )
ft =
General model: ft(a,b,k,x) = b + (a * ((x+k)*(x^-1)) )

Categories

Find more on Linear and Nonlinear Regression in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!