How to write a sum function for lsqnonlin coefficient identification

1 view (last 30 days)
Hello,
I have rather specific question. I am trying to write script, that returns the unknown constants using lsqnonlin function.
The problem is, that the function I am trying to fit is defined with a sum, as follows (if someone is interested, it is a Chaboche model for cyclic plasticity):
k, q are known constants,
y, x are my variables
C and \gamma are unknown constants,
n is number of sums
So for example for n=3, there is C(1), C(2), C(3) and \gamma(1), \gamma(2) to identify (note - the last gamma(n) is equal to zero so that one is known).
The idea is to be able to fit this equation for any positive number of n.
Can you help me with the syntax, how to write it for lsqnonlin? I ended up with this:
n=3;
q=0.02;
k = 200;
C=zeros(1,k)
gamma=zeros(1,k)
x=linspace(-0.02,0.02,1000); %generation of data
%this is my function
for i = n-1
sum= C(i)/gamma(i) * (1 - 2*exp(-gamma(i)*(x+q)));
end
y = k + sum + C(n)*x
myfunction=@(c) k + sum + c(n)*x - y_known %....here is the problem
coeff_fitted=lsqnonlin(myfunction,c,lb);
So I don't know how to input that function as a lsqnonlin argument.
I hope it is clear, since it is quite specific question. Thanks for any help.

Answers (0)

Community Treasure Hunt

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

Start Hunting!