smooth2a

版本 1.0.0.0 (1.3 KB) 作者: Greg Reeves
Smooths a 2D matrix using a mean filter over a user-defined rectangle. Ignores and preserves NaNs.
12.5K 次下载
更新时间 2009/3/13

无许可证

Smooths 2D array data. Ignores NaN's.

function matrixOut = smooth2a(matrixIn,Nr,Nc)

This function smooths the data in matrixIn using a mean filter over a
rectangle of size (2*Nr+1)-by-(2*Nc+1). Basically, you end up replacing
element "i" by the mean of the rectange centered on "i". Any NaN
elements are ignored in the averaging. If element "i" is a NaN, then it
will be preserved as NaN in the output. At the edges of the matrix,
where you cannot build a full rectangle, as much of the rectangle that
fits on your matrix is used (similar to the default on Matlab's builtin
function "smooth").

"matrixIn": original matrix
"Nr": number of points used to smooth rows
"Nc": number of points to smooth columns. If not specified, Nc = Nr.

"matrixOut": smoothed version of original matrix

%%%%%%%%%

Explanation of screenshot:
The left plot is a pcolor (shading interp, axis equal) of a "jagged" 906x1024 matrix. Note that the edges have NaN values (white coloring). On the right, pcolor of output of smooth2a, with Nr = Nc = 50. NaN's are preserved, but do not affect the smoothing of adjacent elements.

引用格式

Greg Reeves (2025). smooth2a (https://ww2.mathworks.cn/matlabcentral/fileexchange/23287-smooth2a), MATLAB Central File Exchange. 检索时间: .

MATLAB 版本兼容性
创建方式 R2007a
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Smoothing 的更多信息
致谢

参考作品: smooth2

启发作品: filt2 2D geospatial data filter

Community Treasure Hunt

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

Start Hunting!
版本 已发布 发行说明
1.0.0.0