Starting from a polynomial coefficient vector such as: [-3/35 12/35 17/35 12/35 -3/35] I would like to create a coefficient matrix of the form:
by iteration of this vector in order to perfrom the Savitzky-Golay signal smoothing. How is this possible without using a for ... loop?

댓글 수: 1

Jan
Jan 2016년 11월 14일
편집: Jan 2016년 11월 14일
Why do you want to avoid a loop? Are you aware that this must be done by a loop, even if it is hidden inside a Matlab command? Why do you want to create a potentially huge matrix with such a low density of information? Note that you have 4 independent values only in your example. Do you want at least a sparse array?
The explicite creation of the matrix is such a waste of time, that a FOR loop will not matter at all. If you want to compute the matrix product also, you loose even more time, because the matrix consists almost only of zeros. Use filter instead.

댓글을 달려면 로그인하십시오.

 채택된 답변

Image Analyst
Image Analyst 2016년 11월 14일

0 개 추천

Why do you want this? Who cares what the coefficients are? Just use sgolayfilt() and be done with it.

댓글 수: 2

Saeid
Saeid 2016년 11월 22일
Thanks for the answer! I didn't have the Matlab module for this fitting so I wanted to program from scratch. I still haven't used the program you have sent but that could solve the problem and save me buying the Matlab module!
You can do the Savitzky-Golay filter yourself. It's essentially just a polynomial fit to a window that slides across the signal. So just have a for loop to have a window move across and use polyfit() to get the polynomial, then use polyval() to get the value at the center of the window.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

질문:

2016년 11월 14일

댓글:

2016년 11월 22일

Community Treasure Hunt

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

Start Hunting!

Translated by