Rank: 3374 based on 33 downloads (last 30 days) and 1 file submitted
photo

Kelly Hilands

E-mail
Company/University
Applied Research Laboratory

Personal Profile:

 

Watch this Author's files

 

Files Posted by Kelly Hilands
Updated   File Tags Downloads
(last 30 days)
Comments Rating
18 Nov 2004 smooth2 Smooths the data in a 2D matrix with a user-defined resolution. Author: Kelly Hilands approximation, interpolation, 2d, smooth, smoothing, matrix 33 13
  • 2.77778
2.8 | 9 ratings
Comments and Ratings on Kelly Hilands' Files View all
Updated File Comment by Comments Rating
23 May 2013 smooth2 Smooths the data in a 2D matrix with a user-defined resolution. Author: Kelly Hilands Right Grievous

I have a problem - your code takes a matrix of mine and after smoothing there are horizontal and vertical 'bars' composed of 0.00444 values. The background is NaN's so these numbers obviously stand out... any ideas why it does this?

27 Jun 2012 smooth2 Smooths the data in a 2D matrix with a user-defined resolution. Author: Kelly Hilands ANAND Kamlapure

its not working properly. Its showing noise along y axis.

11 Apr 2012 smooth2 Smooths the data in a 2D matrix with a user-defined resolution. Author: Kelly Hilands Moritz

23 Aug 2010 smooth2 Smooths the data in a 2D matrix with a user-defined resolution. Author: Kelly Hilands Jakob

I experienced vertical and horizontal jumps in the smoothing and spent quite a while searching for a better alternative when I came across the smooth2a file, found under acknowledgements on this page. If smooth2 fails for you I recommend checking smooth2a out.

21 Jun 2010 smooth2 Smooths the data in a 2D matrix with a user-defined resolution. Author: Kelly Hilands Nathan

Greg Reeves' version indeed runs much faster, but gave me strange results in tests:
A =
1 2 3
4 5 6
7 8 9
smooth2(A,1) =
1.8 3.6 2.6
4.9 8.9 6.2
4.3 7.6 5.1

I switched rows and columns on the eL and eR matrices and was able to obtain results consistent with the documentation of Kelly Hilands' original code (at least for this test):
smooth2(A,1) =
3 3.5 4
4.5 5 5.5
6 6.5 7

Here is the corrected code (two lines are changed from Greg Reeves' code above)

%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,2),1,row)); % THIS LINE CHANGED FROM REEVES' CODE
eR = spdiags(ones(col,2*N(2)+1),(-N(2):N(2)),col,col);
eR = eR./(repmat(sum(eR,1),col,1)); % THIS LINE CHANGED FROM REEVES' CODE

matrixOut = eL*matrixIn*eR;

Contact us