interpolate (using interp) with a decimal number
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
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
Giorgis
2017 年 5 月 2 日
That does the job, but there is some low pass filtering. How this low pass filtering is compared with smooth please? Thanks
Star Strider
2017 年 5 月 2 日
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.
Giorgis
2017 年 5 月 4 日
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!
Star Strider
2017 年 5 月 4 日
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!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の 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)
