numerical integration with borders
Mostra commenti meno recenti
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

Risposte (1)
Star Strider
il 25 Set 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 Commenti
Michael Bond
il 26 Set 2017
Modificato: Michael Bond
il 26 Set 2017
Star Strider
il 26 Set 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.
Categorie
Scopri di più su Logical in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!