-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreadQucsSparams.m
37 lines (29 loc) · 893 Bytes
/
readQucsSparams.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
function [S,Z0,f] = readQucsSparams(qucsDataFile)
% Read variables using QUCS "api"
qucsVars = loadQucsDataSet(qucsDataFile);
% Currently defaults at 50 Ohm
Z0 = 50;
Stemp = [];
Sidxs = [];
% Separate frequency and S-parameters from the rest of the results.
for varIdx = 1:numel(qucsVars)
cVar = qucsVars(varIdx);
% Special case, handle the frequency case
if(strcmp(cVar.name,'frequency'))
f = reshape(cVar.data,[],1);
continue;
end
[values, count,~ ,~] = sscanf (cVar.name,'S[%d,%d]');
% Save positions of values before reshaping
if(count == 2)
Sidxs = [Sidxs ; values(:).'];
Stemp = [Stemp cVar.data(:)];
end
end
Sdims = max(Sidxs,[],1);
S = zeros([Sdims numel(f)]);
% Arrange by dimensions
for sIdx = 1:size(Sidxs,1)
S(Sidxs(sIdx,1),Sidxs(sIdx,2),:) = Stemp(:,sIdx);
end
end