how to use reshape when plotting s-parameters?

조회 수: 5 (최근 30일)
Em
Em 2024년 3월 4일
편집: Umang Pandey 2024년 3월 14일
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!
  댓글 수: 1
Avadhoot
Avadhoot 2024년 3월 13일
Can you share the full code and the .s4p file?

댓글을 달려면 로그인하십시오.

답변 (1개)

Umang Pandey
Umang Pandey 2024년 3월 14일
편집: Umang Pandey 2024년 3월 14일
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

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by