interpolate (using interp) with a decimal number
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
Hi
I'm trying to interpolate using a non-integer number as required by interp command. Is there another function that would allow interpolation using a decimal number please?
Thanks
채택된 답변
Star Strider
2017년 5월 2일
편집: Star Strider
2017년 5월 2일
I am not certain what you are asking. If you have integers and want to interpolate to the nearest integer, use the 'nearest', 'next', or 'previous' method option in your interp1 call.
You could also use the 'linear' method and the use floor, ceil, fix, or round to produce integer output from interp1.
댓글 수: 6
If you try
A = interp(B, 4.2);
You'll get
Resampling rate R must be an integer
I need a function which could take a decimal e.g. 4.2 in this case as the resampling rate. Approximation is not an option unfortunately.
I was not sure what you meant by interp, or what version you are using (Control, System Identification, Signal Processing).
If you have the Signal Processing Toolbox, your best option is probably the resample function, especially since it also uses an anti-aliasing filter. You can use the rat function to get the frequency ratio integers:
[p,q] = rat(4.2)
p =
21
q =
5
That does the job, but there is some low pass filtering. How this low pass filtering is compared with smooth please? Thanks
My pleasure.
The lowpass filtering is the result of the anti-aliasing filter. You actually do want that result, because the interpolation process can introduce spurious signals that will otherwise be aliased to the interpolated result as low-frequency energy, giving you an erroneous result. That is the real strength of the resample function, and the reason not to use the regular interpolation functions, that are not specifically designed for signal processing, for signal processing applications.
I do not have the smooth function since I don’t have the Curve Fitting Toolbox. The documentation says that it uses a moving average filter. Moving average filters can give strange results, as you can see if you plot them with the freqz function. (The core MATLAB smoothdata function uses one of several methods to smooth the data.)
I would use the results of resample for signsl processing, for the reasons I stated. It uses an anti-aliasing filter specifically designed for the particular resampling frequency ratio rather than an arbitrary smoothing filter.
You are quite right. I had to run a few examples and see that the lowpass filter changes the signal insignificantly. Thanks and good day!
Thank you!
My pleasure!
May the Fourth be with you! (Today is ‘Star Wars Day’!)
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Interpolation에 대해 자세히 알아보기
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
