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

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

 采纳的回答

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 个评论

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 个)

类别

帮助中心File Exchange 中查找有关 Interpolation 的更多信息

产品

版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by