How to fit with several infinite serie functions ?
2 views (last 30 days)
Show older comments
clc
clear all
close all
syms L m n
%dbstop if error
x= [0.166666667 1.166666667 2 7.666666667 14.16666667 19.66666667 29.66666667 32.66666667 42.16666667];
y=[0.066508437 0.054771654 0.045643045 0.028689914 0.020865392 0.011736783 0 0 0];
xx = linspace(x(1),x(end),9);
cc=xx.';
figure(1)
plot(cc,y,'bo');
hold on
fun = @(beta,xdata) 512/(pi^6)*symsum(symsum(symsum(1./(exp(-beta(1).*x.*(((2*L+1)*pi/30.81).^2+ ((2*m+1)*pi/30.78).^2+...
((2*n+1)*pi/0.44).^2)).*((2*L+1).^2.*(2*m+1).^2.*(2*n+1).^2)),n,[0 10]),m,[0 10]),L,[0 10]);
betaguess = 3e-6;
betafit = nlinfit(cc,y,fun,betaguess);
plot(cc,fun(betafit,cc),'g-')
legend('Data','Fitted exponential')
title('Data and Fitted Curve')
Hi all, i am dealing with the fickian equation as follows. Try to use none linear fit. In the code, t,mt/msat is input as x,y. Using curve fitting get the best D value. However, it doesn,t work well. Is there anyway to do this in matlab?

0 Comments
Answers (1)
David Hill
on 2 Mar 2020
x=0:100;%I only went to 100 for the summations.
x0=1;%not sure what these should be
y0=1;
z0=1;
t=0.166666667;%first value of x
n=repmat(x,1,10000);
m=repmat(repelem(x,1,100),1,100);
l=repelem(x,1,10000);
Leqv2=((2*l+1)*pi/x0).^2+((2*m+1)*pi/y0).^2+((2*n+1)*pi/z0).^2;
m=@(D)1-(512/pi^6)*sum(exp(-D*t./Leqv2)./((2*l+1).^2.*(2*m+1).^2.*(2*n+1).^2));
for d=15:.1:25%whatever step you want
if abs(m(d)-0.066508437)<.001%first value of y (whatever tolerance you want
break;
end
end
% you could also plot y vs. d for each value of x.
d=0:100
y=arrayfun(@(D)m(D),d);
plot(d,y);
0 Comments
See Also
Categories
Find more on Calculus 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!