Rank: 1428 based on 108 downloads (last 30 days) and 1 file submitted
photo

Greg Reeves

E-mail
Lat/Long
34.138844, -118.12699

Personal Profile:
Professional Interests:

 

Watch this Author's files

 

Files Posted by Greg
Updated   File Tags Downloads
(last 30 days)
Comments Rating
13 Mar 2009 Screenshot smooth2a Smooths a 2D matrix using a mean filter over a user-defined rectangle. Ignores and preserves NaNs. Author: Greg Reeves 2d, approximation, interpolation, mathematics, matrix, smooth 108 8
  • 5.0
5.0 | 8 ratings
Comments and Ratings by Greg
Updated File Comments Rating
12 Mar 2009 smooth2 Smooths the data in a 2D matrix with a user-defined resolution. Author: Kelly Hilands

I took out the for loops and just used array algebra to do essentially the same thing. Improved speed ~10 fold. I didn't bother checking whether edge behavior is the same. My edge behavior is similar to the default behavior in Matlab's builtin smooth function.

%Initial error statements and definitions
if nargin<2, error('Not enough input arguments!'), end

N(1) = Nr;
if nargin<3
N(2) = N(1);
else
N(2) = Nc;
end

if length(N(1))~=1, error('Nr must be a scalar!'), end
if length(N(2))~=1, error('Nc must be a scalar!'), end

[row,col] = size(matrixIn);
eL = spdiags(ones(row,2*N(1)+1),(-N(1):N(1)),row,row);
eL = eL./(repmat(sum(eL,1),row,1));
eR = spdiags(ones(col,2*N(2)+1),(-N(2):N(2)),col,col);
eR = eR./(repmat(sum(eR,2),1,col));

matrixOut = eL*matrixIn*eR;

Comments and Ratings on Greg's Files View all
Updated File Comment by Comments Rating
18 Oct 2013 smooth2a Smooths a 2D matrix using a mean filter over a user-defined rectangle. Ignores and preserves NaNs. Author: Greg Reeves Kieran

04 Sep 2013 smooth2a Smooths a 2D matrix using a mean filter over a user-defined rectangle. Ignores and preserves NaNs. Author: Greg Reeves Stephanie

24 Jan 2011 smooth2a Smooths a 2D matrix using a mean filter over a user-defined rectangle. Ignores and preserves NaNs. Author: Greg Reeves PsiCom, JEC

I get this error trying to run the code on a 2-D matrix of type double:

"MTIMES is not supported for one sparse input and one single input."

What does this mean?

02 Jan 2011 smooth2a Smooths a 2D matrix using a mean filter over a user-defined rectangle. Ignores and preserves NaNs. Author: Greg Reeves Toljic, Nikola

Thanks.

07 Dec 2010 smooth2a Smooths a 2D matrix using a mean filter over a user-defined rectangle. Ignores and preserves NaNs. Author: Greg Reeves Novak, Mark

Thank you... this is perfectly implemented.

Contact us