필터 지우기
필터 지우기

How do I export data from an .s2p file in MATLAB?

조회 수: 111 (최근 30일)
Alexandria Will-Cole
Alexandria Will-Cole 2018년 11월 27일
답변: Mark 2022년 6월 7일
Hi,
I have a sequence of .s2p touchstone files that I need to analyze data from. I am currently using the RF toolbox and have used these commands to export the data:
%load in touchstone s2p data file
data = read(rfdata.data,myfilename);
%sort by data
freq = data.Freq;
s_params = extract(data,'S_PARAMETERS',50);
% data
s11 = s_params(1,1,:);
s22 = s_params(2,2,:);
s21 = s_params(2,1,:);
s12 = s_params(1,2,:);
However, I'd prefer to export the data in a more manual way and not use the toolbox command, because I'm not sure if it is identifying the correct columns of data... it doesn't make 100% sense when I do this. Is there a way I can open the file and import the file as a matrix then seperate out the data? I'm thinking of using something like this:
f = myfilename(:,1); ReS11 = myfilename(:,2); ImS11 = myfilename(:,3); ReS21 = myfilename(:,4); ImS21 = myfilename(:,5); ReS12 = myfilename(:,6); ImS12 = myfilename(:,7); ReS22 = myfilename(:,8); ImS22 = myfilename(:,9);
%Creating the S Parameter Matrix
s11=ReS11+1i*(ImS11);
s12=ReS12+1i*(ImS12);
s21=ReS21+1i*(ImS21);
s22=ReS22+1i*(ImS22);
I just am not sure how to actually get the data imported into my MATLAB script in an automated way. Please help!
Thanks,
  댓글 수: 2
Alexandria Will-Cole
Alexandria Will-Cole 2018년 11월 27일
I understand the file format of touchstone files, but my coding in MATLAB is still novice. I just want to know how to import the .s2p file into MATLAB without using the RF Toolbox in MATLAB, because it is not importing correctly. How can I do this manually in MATLAB?I also want my code to be fairly generic in case I want to change languages from MATLAB to something like python.

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

채택된 답변

Mark
Mark 2022년 6월 7일
The RF Toolbox offers an sparameters object that can read in and manipulate data from Touchstone files
>> obj = sparameters('passive.s2p')
obj =
sparameters: S-parameters object
NumPorts: 2
Frequencies: [202×1 double]
Parameters: [2×2×202 double]
Impedance: 50
rfparam(obj,i,j) returns S-parameter Sij
The RF Toolbox also offers many functions for manipulating and plotting S-parameter data.

추가 답변 (1개)

Alexandria Will-Cole
Alexandria Will-Cole 2018년 11월 27일
Okay, I just noticed the first link. The only problem I have with that is that they are reading in a text file. Do you know how I can change the file extension on my .s2p files within my script? There are too many to do prior to the code.

카테고리

Help CenterFile Exchange에서 Data Import and Network Parameters에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by