フィルターのクリア

Using an array inside a function

2 ビュー (過去 30 日間)
Ben Hendrickson
Ben Hendrickson 2021 年 2 月 12 日
回答済み: Star Strider 2021 年 2 月 12 日
I have a spectral block (512,512,16) that can be thought of as the output from a multiband image sensor (16 spectral slices). I'd like to integrate over the slices to produce a single image (512,512). The integral includes a wavelength term, so I figured it'd be best to use a function handle, but I can't reason a way to operate on the entire block all at once. I could loop through pixel by pixel, but I'm sure there's a more clever way to go about this. Thoughts?
Thanks,
Ben

採用された回答

Star Strider
Star Strider 2021 年 2 月 12 日
Try something like this, using trapz:
SB = randn(512,512,16); % Create Matrix
Lambda = 1./(1:16); % Create Wavelength Vector (Guessing Here)
IntSB = trapz(Lambda,SB,3); % Numerical Integration Over Dimension #3
The result will be a (512,512) matrix.
Also consider cumtrapz, depending on the result you want.

その他の回答 (0 件)

製品


リリース

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by