Clear Filters
Clear Filters

Smoothing the data for different windowsizes (for loop)

1 view (last 30 days)
I have a for loop for different windowsize to smooth the data.
My m file first reads the xlsx file that I want to smooth. Then I have the windowsize for loop which looks like this:
for windowsize=[1,5:5:180]
...
%%%here there are various calculations that I want to do for each windowsize
...
%%%right at the bottom of the mfile there is end for the windowsize loop.
end
I get different results when I just use a particular windowsize (eg for windowsize=100) than when I use the for loop for lots of windowsize (eg for windowsize=[1,5:5:180])
It differs hugely when the windowsize is large.
Is it because I am smoothing the data that I have already smoothed with the previous windowsize?
But within the windowsize for loop, I have added a line which has the raw data so after it is done with the first windowsize, it should return back to the raw data and smooth it with the next windowsize.
I don't know what else would affect the results.

Accepted Answer

Walter Roberson
Walter Roberson on 25 Aug 2015
I suggest you move the body of the loop into a new routine and pass appropriate values to it, and return the necessary values. That way you know that any variables that are local to the new function are going to be reset each time the function is called.

More Answers (0)

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!