Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

read in text from s2p file

190 views
Skip to first unread message

Philip Brennan

unread,
Feb 5, 2014, 9:22:08 AM2/5/14
to
I want to read in this code to matlab in matrix form.
I have an *.s2p file and want to ignore, all '#' and '!' when reading the data in. So as I only read in lines with numbers on them only.

any ideas on how I can do this?
An example of the code is below, I also do not have the RF toolbox.

any help would be appreciated.



# GHZ S MA R 5.000000
! Modal data exported
! Port[1] = 1:1
! Port[2] = 2:1
0.1 0.0157914773946054 -96.7999885509295 0.998916096857863 -2.49985583066194 0.998916096857846 -2.49985583066178 0.0156170415937393 -89.1714329993457
! Gamma ! 0.0697413076489605 3.72715385179791 0.0701450080445555 3.73301289162699
! Port Impedance 50 0 50 0

0.2 0.0310983142614545 -98.0129281092563 0.997809972707363 -4.95959533725871 0.997809972707317 -4.95959533726457 0.0309443094888351 -94.0255594147918
! Gamma ! 0.110261068543901 7.40377005558056 0.110953134876849 7.41515346255415
! Port Impedance 50 0 50 0

dpb

unread,
Feb 5, 2014, 9:36:22 AM2/5/14
to
Are linefeeds properly reflected here as compared to the actual file?
That is, are the "! Gamma !" strings embedded in a line as shown?

If so, it's a mishmash of stuff...looks like repetitive calls to
*textscan* to read each section. Wrap those into to calls to build a
routine for the whole file. The first four are easy enough with
'headerlines' and/or the 'commentstyle' parameters. Unfortunately, TMW
didn't allow for multiple single-line comment characters so you have to
choose one and the bracketed comment style using "!" won't work because
it's not consistent in the file.

Or, there's always regexp() ...

--

0 new messages