MATLAB User Specifying a Fit Function in a Separate File

  • Thread starter teroenza
  • Start date
192
3
I have five data points (x,y,z), with two independent variables (x,y), and have written a function in a separate file z = f(x,y,A,B,C), with three undetermined constants (A,B,C).

How can I use a Matlab fitting program to try and determine the constants? I've written a fit function before where I included a string as the user-spesified fitting function, but am not sure how to tell it to call my function in a separate file.
 
192
3
I have tried, for example:

Code:
x               = [11/2 11/2 11/2 13/2 13/2]'; % F
y               = [9/2 11/2 13/2 11/2 13/2]'; % Fprime
z               = [0.117 0.114 0.110 0.156 0.151]';

ft = fittype('HyperfineShiftFunction( [x, y], Aprime, Bprime, offset )');
f  = fit( [x, y], z, ft )
Where HyperfineShiftFunction is the separate function file. Matlab complains that "The name y cannot be used for both a coefficient and the dependent variable.". I've tried looking into how to tell it that both x and y are independent, but have not succeeded.
 

Want to reply to this thread?

"User Specifying a Fit Function in a Separate File" You must log in or register to reply here.

Related Threads for: User Specifying a Fit Function in a Separate File

Replies
1
Views
2K
Replies
0
Views
309
Replies
1
Views
2K
Replies
1
Views
2K
Replies
4
Views
3K
  • Posted
Replies
2
Views
3K
Replies
1
Views
2K
  • Posted
Replies
3
Views
644

Physics Forums Values

We Value Quality
• Topics based on mainstream science
• Proper English grammar and spelling
We Value Civility
• Positive and compassionate attitudes
• Patience while debating
We Value Productivity
• Disciplined to remain on-topic
• Recognition of own weaknesses
• Solo and co-op problem solving
Top