Riemann sum to find the area between two curves
조회 수: 1 (최근 30일)
이전 댓글 표시
I'm trying to find the Riemann sum of the area between two curves as shown in the diagram below. Xn is rescaled and a new data set is the difference between Xc and rescaled data. I need to take the Riemann sum over the region between these two (Xc and (Xn rescaled) data).
I have coded that as below, but I'm not sure how to take the Riemann sum of these data poionts.
phi = linespace(1,100,1)%array of 100 values
sol_n=xn.sol_all; %this is a 1500*100 data set
sol_c=xc.sol_all; %this is a 1500*100 data set
for i =1:length(phi)
Xn_new= (sol_n(:,i)).*((sol_c(end,i))./(sol_n(end,i))); %Rescaling Xn
Xc_new = sol_c(:,i);
Data = Xc_new- Xn_new;
end
Your help is greatly appreciated.
댓글 수: 0
채택된 답변
Cameron
2023년 3월 3일
x = 0:0.01:1; %some x data
s1 = x./(x+exp(1-7*x)); %some y data
s2 = x./(x+exp(1-10*x)); %some other y data
plot(x,s1,'b',...
x,s2,'r')
sumS1 = trapz(x,s1); %trapezoidal integration
sumS2 = trapz(x,s2); %trapezoidal integration
sumBetween = sumS2 - sumS1 %subtract the two for answer
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Numerical Integration and Differential Equations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!