how to use reshape when plotting s-parameters?

2 views (last 30 days)
Em
Em on 4 Mar 2024
Edited: Umang Pandey on 14 Mar 2024
I'm following one of the previous solutions to try to solve my problem (https://uk.mathworks.com/matlabcentral/answers/1894865-how-can-i-plot-s-parameter-of-differential-signal-sdd21-on-matlab?s_tid=ta_ans_results)
My code is as follows:
s4p_dbm0 = dbm_0.Parameters;
sdd_dbm0 = s2sdd(s4p_dbm0);
SDD_Parameters_0dBm=(abs(reshape(sdd_dbm0,4,101,1)))';
Unfortunately, when I try to reshape, I get an error message.
Error using reshape
Number of elements must not change. Use [] as one of the size inputs to automatically calculate
the appropriate size for that dimension.
But if I change 4 to [] then it also won't plot. My issue is that I don't understand what the reshape is doing really here, can someone explain where I'm going wrong?
My s-param dimensions are 2x2x101
Thanks!

Answers (1)

Umang Pandey
Umang Pandey on 14 Mar 2024
Edited: Umang Pandey on 14 Mar 2024
Hi Em,
The error indicates a mismatch in the number of elements due to the incompatibility of dimensions while reshaping.
Although I can't point out the specific issue since you have not shared your code, it is most likely occurring because you have not incorporated the change in dimensions after using the 's2ssd' function.
The s2ssd function, as stated in the documentation, converts the 2N-port, single-ended S-parameters to N-port, differential-mode S-parameters. Thus, if the dimension of "s4p_dbm0" is (2 X 2 X 101), the dimensions of "sdd_dbm0" will be (1 X 1 X 101). You will have to reshape, keeping the total number of elements equal to that of "sdd_dbm0", which is 101.
You can also check the following code for reference:
S = sparameters('default.s4p');
s4p = S.Parameters; % Dimension of s4p -> 4 X 4 X 1496
s_dd = s2sdd(s4p); % Dimension of s_dd -> 2 X 2 X 1496
SDD_Parameters_0dBm=(abs(reshape(s_dd,[],1496))); % Dimension of SDD_Parameters_0dBm -> 4 X 1496
Hope this helps!
Best,
Umang

Categories

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

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!