Why my integration is like this?
조회 수: 1 (최근 30일)
이전 댓글 표시
Hello everyone,
Actually, I have some data from my experiment which is as follows:
![dsc.jpg](https://www.mathworks.com/matlabcentral/answers/uploaded_files/241831/dsc.jpeg)
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](https://www.mathworks.com/matlabcentral/answers/uploaded_files/241832/hit_dsc.jpeg)
댓글 수: 3
답변 (1개)
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
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
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 Center 및 File Exchange에서 Interpolation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!