Satisfying the complex NxNxM requirement in s2rlgc function

Hello world,
I am trying to convert some s-parameters to the RLGC values using matlabs s2rlgc function. (It comes with the RF toolbox). However so far it has been able to do so for one individual value of s parameters. For example, I run the following script.
S_11 = 2.80007716585167 - 194.777061344490i;
S_12 = 1.01738305506126 + 0.00852418806674031i;
S_21 = 1.00027791458013 + 6.81079834005747e-07i;
S_22 = 10.1134655629712 + 0.881321459087057i;
freq = 40000000000;
% put the 4 s-parameters in a matrix
s_params = [S_11,S_12; S_21,S_22];
length = 4.5;
z0 =50;
sparams_passive = makepassive(all_s_params);
rlgc_params = s2rlgc(sparams_passive,length,freq,z0);
disp(rlgc_params)
and it will output
R: -9.3154
L: -2.5604e-10
G: 0.0036
C: 9.9513e-14
alpha: 1.2686
beta: -0.1837
Zc: 0.0012 -50.7238i
into the command window. The problem is that I have a 3202x2 complex double of s paramters since I took them in from a VNA(vector network analyzer; equipment from lab) As you can see from the line of code above, the S parameters form in 4 complex numbers, and so in the s_params matrix, they come out as a 3202x2 complex double. I also have a frequency 1601x1 double that corresponds with each set of s parameters.
I would love to run them all at once. When I try to do so I get error messages that say "S_PARAMS must be a complex NxNxM array."
I am not sure what is meant by NxNxM array. Does anyone have an idea?

8 Comments

Hi Jesus,
Take a look at 'doc s2rlgc'. You have 1601 frequencies, and you need to make a 2x2x1601 array S, each layer of which is a 2x2 matrix [S11 S12; S21 S22] for that frequency. The 3202x2 array (call it A) has the values and it's just a question of how it is organized. For example if it looks like
S11 S12 freq 1
S21 S22 freq 1
S11 S12 freq 2
S21 S22 freq 2
...
then each layer of S is constructed from two rows of A, which can be accomplished with a for loop or otherwise.
Hi David,
Thank you for the reply and help. The 3202x2 matrix is organized like this;
A = 1st value of array :[ S11 S12 ]
. .
. .
. .
the 1602nd value S21 S22
. .
. .
. .
3202 value of the array [ S21 S22 ]
So the corresponding S21 and S22 values for the first frequency are found in the 1602 spot of array A. Also the frequency is in a separate 1601x1 array.
I'm guessing it is still possible to make the 2x2x1601 array, I'll just have to extract them from the two arrays?
Its been a while since I've delt with 2d(/3d) array loops but I'll give it a try.
Hi Jesus,
This looks like a favorable situation, where for loops are not necessary. If you preallocate S as zeros(2,2,1601) then for example for S11,
S(1,1,:) = A(1:1601,1). And so forth.
Hi David,
I understand and it seems like this should work. The attached picture shows S11 successfully placed in the matrix(although the value are being multiplied by some factor of 10 and I don't know why) Although I am trying to complete transferring the values this way;
S(1,1,:) = A(1:1601,1); %S11
S(1,2,:) = A(1,1:1601); %S12
% S(2,1,:) = A(1602:3202,1); %S21
% S(1,2,:) = A(2,1601:3202); %S22
Just by running the second line I get this error:
Index in position 2 exceeds array bounds (must not exceed 2).
Error in matlab_code_testing (line 60)
S(1,2,:) = A(1,1:1601); %S12
Is the syntax wrong?
Hi Jesus,
S12 is in the second column of A, which is A(1:1601,2) and similarly S22 is in the second column which is A(1602:3202,2). Also there is a mistake on your last line where you meant S(2,2,:).
Just saw the comment above, thank you I will try it that way to make sure it works out.Compared to me getting the S values into the 2x2x1601 array using the slightly different method, but now I have stumbled across another problem. This is the error message I now see,
Operands to the || and && operators must be convertible to logical scalar values.
Error in s2rlgc (line 129)
if any(isnan(R) || isnan(L) || isnan(G) || isnan(C))
Error in matlab_code_testing (line 68)
rlgc_params = s2rlgc(sparams_passive,length,F,z0);
I have attached a screenshot of it as well.
I don't have the RF toolbox so I can't say much. I guess all I could suggest is
plot(abs(S(1,1,:)))
and
plot(angle(S(1,1,:)))
just to see if they make sense. And similarly for S(1,2,:) etc.
Thanks David,
You helped get a passed some hurdles. I am still working this code but working on another module first. I'll get back to this one sooner rather than later hopefully

Sign in to comment.

Answers (1)

Hi,
with the data in the following form
A = 1st value of array :[ S11 S12 ]
. .
the 1602nd value S21 S22
. .
3202 value of the array [ S21 S22 ]
I would use reshape like this
M = 1601; % size() or length() would be better
B = [A(1:M,1),A(M+1:end,1),A(1:M,2),A(M+1:end,2)].'; % Creates a Matrix of row vectors [s11;s21;s12;s22]
S = reshape(B,[2,2,M]); % creates NxNxM matrix from B
this should work as input for s2rlgc.

Categories

Find more on Data Import and Network Parameters in Help Center and File Exchange

Asked:

on 27 Jun 2018

Answered:

on 23 Feb 2019

Community Treasure Hunt

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

Start Hunting!