Why my integration is like this?

1 次查看(过去 30 天)
Faezeh Manesh
Faezeh Manesh 2019-10-9
Hello everyone,
Actually, I have some data from my experiment which is as follows:
dsc.jpg
I am trying to integrate the above curve. So, I fitted a curve to this (using multiple gaussian terms in cftool) and used the resulted function to integrate my data as follows:
clc
clear all
%result of the cftool for 5 gaussian fit to the experimental data
syms f(x)
f(x)= (0.05644*exp(-((x-65.1)/2.813).^2))+(0.08694*exp(-((x-63.1)/1.605).^2))+(0.07148*exp(-((x-61.7)/1.085).^2))+...
(0.03588*exp(-((x-69.23)/5.666).^2));
%integrate the above function
f7 = int(f,x)
% reading my experimental data
[d,s,r] = xlsread('DSCtest.csv');
T = d(:,1);
y = f7(T);
y2=double(y);
plot(T, f7(T))
Then, I plotted the resulted curve (result of integral) and the original curve at a same sheet. But the result doesn't make sense. Because, as you can see,at the beggining of the blue curve ( until x=60) y is zero and the integral should be zero too. while the integral becomes negative here. Do you know what is going on here?
I have also attached my experimental data here.
hit_dsc.jpg
  3 个评论
Walter Roberson
Walter Roberson 2019-10-10
Your claim was that the integral should be 0 between 0 and 60.

请先登录,再进行评论。

回答(1 个)

Fabio Freschi
Fabio Freschi 2019-10-9
You are calulating an indefinte integral that has an integration constant by definition. Matlab int command doesn't add the integration constant, so your solution could be translated. If you integrated numerically, you will see the same "shape" of your solution, only translated:
I = cumtrapz(d(:,1),d(:,2));
figure,plot(d(:,1),I);
  3 个评论
Walter Roberson
Walter Roberson 2019-10-10
syms b x
simplify(subs(int(f,x),x,b) - int(f,0,b))
ans =
-(pi^(1/2)*(3877790*erf(12340/217) + 6976935*erf(12620/321) + 10164804*erf(34615/2833) + 7938286*erf(65100/2813)))/100000000
double(ans)
-0.513263907105595
Therefore Fabio's suggestion that you have an issue involving the constant of integration is correct.
Fabio Freschi
Fabio Freschi 2019-10-10
cumtrapz gives you a "point to point integration" and it is rather smooth, because you have a fine sampling of your original data. Try to run the two lines after you read the experimental data (copied here for your convenience)
I = cumtrapz(d(:,1),d(:,2));
figure,plot(d(:,1),I);

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Interpolation 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by