numerical integration with borders
이전 댓글 표시
Hello everybody,
i have the spectral response data (xy) from a camera:
x: 451x1 double y: 451x1 double (red curve in the picture)
in front of the camera, I will mount an optical filter. This filter will only transmit light in a given range. For that purpose I want to integrate the spectral response curve of the camera (the xy Data)in the range of the filter. I've read about cumtrapz, but I don't know how to tell it to matlab, especially the borders.
Many thanks for your help.
Michael

답변 (1개)
Star Strider
2017년 9월 25일
One approach:
x = linspace(350, 1100, 2000); % Create Data
y = sin(2*pi*x/50) + 2; % Create Data
select = (x >= 600) & (x <= 650); % Create Data
xs = x(select);
ys = y(select);
int_select = cumtrapz(xs, ys); % Integrate
figure(1)
plot(x, y)
hold on
patch([xs fliplr(xs)], [zeros(size(ys)) fliplr(ys)], 'k')
hold off
grid
axis([min(x) max(x) 0 4])
text(625, 3.5, sprintf('Area = %.3f', int_select(end)))
댓글 수: 2
Michael Bond
2017년 9월 26일
편집: Michael Bond
2017년 9월 26일
Star Strider
2017년 9월 26일
My code worked with the data I created. I have no idea what the problem is with your getting an empty result.
One possibility could be the units your ‘xi’ data are in. You may want to check those, then create the ‘select’ limits to include the appropriate range.
카테고리
도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!