Cascading a User Definable number S Parameter objects together

14 ビュー (過去 30 日間)
Reid Kinder
Reid Kinder 2020 年 1 月 26 日
コメント済み: Reid Kinder 2020 年 1 月 27 日
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 件のコメント
Jeff Miller
Jeff Miller 2020 年 1 月 27 日
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 2020 年 1 月 27 日
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

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeGraphics Object Programming についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by