MATLAB Answers

Cascading a User Definable number S Parameter objects together

9 views (last 30 days)
Reid Kinder
Reid Kinder on 26 Jan 2020
Commented: Reid Kinder on 27 Jan 2020
I am trying to cascade a number of S Parameter objects together. This number is user defineable. I am using the RF Toolbox command "sparameters" to read an .s2p file. The program asks for the number of files that the user wishs to input, then asks for their file names, and stores all the S Parameter objects in the same matrix "SPara".
The program then plots the individual file response. Followed by cascading the two S Parameter objects through the "cascadesparams" command, then plotting the cascaded response. I am able to cascade the files when only processing 2 files because I simply reference the two objects in the SPara matrix with in the "cascadesparams" command. However, the size of the SPara matrix is dependent on the number of files the user wishes to input. How do cascade based on the number of files the user inputs? The end result I would like to make a fuction that I can call any time. Here is my code:
%function S = importSpara()
n = input('Input number of files to be imported & cascaded:\n');
for x = 1:n
SPara(1,x) = sparameters(input('Input file name:\n'));
end
for i = 1:n
figure
rfplot(SPara(1,i))
end
SParaCasc = cascadesparams(SPara(1,1), SPara(1,2));
figure (3)
rfplot(SParaCasc)
%end

  0 Comments

Sign in to comment.

Answers (1)

Jeff Miller
Jeff Miller on 27 Jan 2020
Maybe this?
n = input('Input number of files to be imported & cascaded:\n');
SPara= cell(1,n);
for x = 1:n
SPara{x} = sparameters(input('Input file name:\n'));
end
for i = 1:n
figure
rfplot(SPara{i})
end
SParaCasc = cascadesparams(SPara{:});
figure (3)
rfplot(SParaCasc)

  3 Comments

Reid Kinder
Reid Kinder on 27 Jan 2020
Sadly, that just replots the response for the first file...
Jeff Miller
Jeff Miller on 27 Jan 2020
OK, sorry for the distraction. I thought that syntax would convey all of the SPara's to cascadesparams, but apparently that isn't enough. It might be worth looking at whether SParaCasc actually does represent the cascade of all n SPara's with this syntax.
Reid Kinder
Reid Kinder on 27 Jan 2020
No problem. I have figured it out though. Just in case you were wondering here is the code.
%function S = importSpara()
n = input('Input number of files to be imported & cascaded:\n');
for x = 1:n
SPara(1,x) = sparameters(input('Input file name:\n'));
end
for i = 1:n
figure
rfplot(SPara(1,i))
end
SParaCasc = SPara(1,1);
for ii = 1:n-1
SParaCasc = cascadesparams(SParaCasc,SPara(1,ii+1));
end
figure(n+1)
rfplot(SParaCasc)
%end

Sign in to comment.

Sign in to answer this question.