Curve fitting with a custom function
2 次查看(过去 30 天)
显示 更早的评论
Hey guys, I am trying to do curve fitting in MATLAB with a custom function that I created with a script file. What I am precisely trying to do is to determine the term d from the following expression: C1=1+ 4/π ∑_(n=1)^1000▒〖〖(-1)〗^n/((2n-1)) cos[(n-1/2)π((-1)/2)×e^[-〖(n-1/2)〗^2×π^2×d/4 t] ] 〗. So basically, I have the values that correspond to C1, the time points and I am trying to determine d; As you can see I have a summation and an exponent term. The script I wrote in Matlab is the following one: function C1=Conc(t,D) C1=zeros(1,16);%make a table in order to save C1 values for each one of the time points C0=0;%Initiation of the summation term z=2;%Contact interface cartilage-bath h=2;%Cartilage height %D is the diffusion coefficient that we are looking for %t corresponds to the different time points for j=1:16 for i=1:1000 C=((-1)^i)/(2*i-1)*(cos((i-0.5)*pi*(-0.5)))*(exp(-((i-0.5)^2)*pi^2)*(D/4)*t); C=C0+C; end C1(j)=1+((4/pi)*C); end I defined two loops; the first one for the 16 different time points that I have and the other one for the summation term. I am getting a mistake concerning the dimensions of the arrays that I am using. Could you please give me some feedback with respect to the validity of the script that I am writing in order to fit the specific equation? Thanks in advance, Asimina
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Interpolation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!