numerical integration with borders
Ältere Kommentare anzeigen
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

Antworten (1)
Star Strider
am 25 Sep. 2017
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 Kommentare
Michael Bond
am 26 Sep. 2017
Bearbeitet: Michael Bond
am 26 Sep. 2017
Star Strider
am 26 Sep. 2017
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.
Kategorien
Mehr zu Logical finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!