Does Matlab have a command to make data smoother like the smooth command in IDL?

Asked by Nopparat on 9 Sep 2012
Latest activity Answered by Sean de Wolski on 11 Sep 2012

Does Matlab have a command to make data smoother like the smooth command in IDL?

For IDL command,

"The SMOOTH function returns a copy of Array smoothed with a boxcar average of the specified width. The result has the same type and dimensions as Array" ( http://idlastro.gsfc.nasa.gov/idl_html_help/SMOOTH.html). The example of the result is following;

The original data

       7.79008      4.15141      7.48622
       1.69548      6.31630      6.84862
       7.00782      2.78159      7.85362
       5.91996     0.659594      5.77286
       8.38353      3.33698      9.03057
       7.64424     0.474168      5.77164
       3.62966      8.94523      4.11056
       9.33464      1.19968      4.66864
       5.79112      3.83709      1.43494

The result data ( IDL> print, smooth(x,3,/edge) )

       5.31274      5.66250      6.01227
       5.21623      5.58725      5.95827
       5.11973      5.51200      5.90428
       5.42783      5.47206      5.51628
       5.41093      5.25468      5.09842
       5.39403      5.03729      4.68056
       5.54293      5.28162      5.02030
       5.60563      4.92210      4.23857
       5.66832      4.56258      3.45685

Thank you in advance.

0 Comments

Nopparat

Tags

Products

No products are associated with this question.

3 Answers

Answer by Image Analyst on 9 Sep 2012
Accepted answer

Ordinarily I'd do this:

smoothed_m = conv2(m, ones(3)/9, 'same')

but modified to fix any edge effects:

numerator = conv2(m, ones(3), 'same')
denom = conv2(ones(size(m)), ones(3), 'same')
smoothed_m2 = numerator ./ denom

but it doesn't give you the same output values. However I'm not sure how you got those values. For example, let's take the middle value, which is totally not affected by edge effects. You say it's 5.25468 however in MATLAB:

m9 = [...
	 5.91996     0.659594      5.77286
       8.38353      3.33698      9.03057
       7.64424     0.474168      5.77164]
averageValue = mean2(m9)
averageValue =
    5.2215

which doesn't match your number. You'll have to define boxcar.

1 Comment

Nopparat on 11 Sep 2012

Thank you very much!

Image Analyst
Answer by Rick Rosson on 9 Sep 2012
   >> doc ones
   >> doc filter

0 Comments

Rick Rosson
Answer by Sean de Wolski on 11 Sep 2012

If you have the Curve Fitting Toolbox:

doc smooth

0 Comments

Sean de Wolski

Contact us