Cascading a User Definable number S Parameter objects together

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

답변 (1개)

Jeff Miller
Jeff Miller 2020년 1월 27일
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

Sadly, that just replots the response for the first file...
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.
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

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

제품

릴리스

R2019a

질문:

2020년 1월 26일

댓글:

2020년 1월 27일

Community Treasure Hunt

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

Start Hunting!

Translated by