Why is the 'rfinterp1' function creating a jagged line between data points?

7 ビュー (過去 30 日間)
I have an S-parameter object for which I am plotting the parameter values. I want to draw a line connecting the data points using linear interpolation. However, when I use the function 'rfinterp1', I see a jagged line instead of a linear one as shown below. Why is this happening?
 
Example script:
>> y = rfparam(sobj_raw_s4p, 2, 1);
>> x = sobj_raw_s4p.Frequencies;
>> xnew = f_s4p;
>> ynew = interp1(x, y, xnew);
>> figure; hold on; plot(x, db(abs(y)), 'o'); plot(xnew, db(abs(ynew)), '-'); hold off

採用された回答

MathWorks Support Team
MathWorks Support Team 2021 年 2 月 16 日
The 'rfinterp1' function is behaving as expected. The difference in the data and the interpolation is due to the fact that the data is complex. When interpolating complex numbers, 'interp1', the function behind 'rfinterp1', interpolates the real and imaginary parts separately.
There are two ways to resolve this, depending on your desired results.
Option 1:
The 'rfinterp1' function should interpolate the abs( ) of the 'sobj_raw_s4p' data. You can do this by putting the following command after the definition for 'sobj_raw_s4p'. For the data to line up with the interpolation, this command should be used after the definition of 'sobj_raw_s4p' for the raw data as well.
>> sobj_raw_s4p.Parameters = abs(sobj_raw_s4p.Parameters);
 
Option 2:
You can plot the real and/or imaginary parts separately. This would look like replacing the 'abs( )' command with the 'real( )' or 'imag( )' commands in all the 'plot' functions.
  1 件のコメント
Walter Roberson
Walter Roberson 2024 年 3 月 23 日
Ritesh Bhat comments
I think Option 1 modifies the original s-parameters themselves and must be used carefully. For instance, if we want to cascade two s-parameters using cascadesparams function after interpolation, this may give the wrong result.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeInterpolation についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by