Clear Filters
Clear Filters

I want to read ascii file into matlab which has 191 rows and 9 columns. Then I have to convert it into matrix form that too row wise also I have to convert magnitude and angle into real and imaginary parts.

2 views (last 30 days)
The data below is in 9 columns. The first column is for frequency, which is in hertz. The second column is for S11 magnitude, the third for S11 angle, the 4th column is S12 magnitude, the 5th is S12 angle and so on. All eight columns are S-parameters which are in magnitude and angle and I have to take them row by row, and read this data directly into matlab, and then form a matrix. Then I have to convert it into real and imaginary parts.
. # Hz S MA R 50
row 1 : 1000000000.000 +9.8103468350E-001 -1.1212773233E+001 +7.5138900895E-002 +6.7503685995E+001 +7.5911915353E-002 +7.7612286233E+001 +6.6197497335E-001 -5.5698989097E+000
row 2 : 1100000000.000 +9.7789664654E-001 -1.2343173752E+001 +8.2372076274E-002 +6.7164745132E+001 +8.3032257289E-002 +7.6655276053E+001 +6.6534801460E-001 -6.0731137365E+000
row 3 : 1200000000.000 +9.7414597496E-001 -1.3450479844E+001 +8.9137342173E-002 +6.6984995092E+001 +9.0037093048E-002 +7.5847505505E+001 +6.6377100820E-001 -6.7338426347E+000
row 4 : 1300000000.000 +9.7079182625E-001 -1.4524257360E+001 +9.6368252287E-002 +6.6520385977E+001 +9.7232350444E-002 +7.4786965364E+001 +6.6260679152E-001 -7.1749452934E+000
row 5 : 1400000000.000 +9.6708627191E-001 -1.5607081020E+001 +1.0320309179E-001 +6.6173275207E+001 +1.0372396159E-001 +7.3691071630E+001 +6.6218596876E-001 -7.6584585544E+000
row 6 : 1500000000.000 +9.6345447413E-001 -1.6659061335E+001 +1.0998283042E-001 +6.5718349968E+001 +1.1088458742E-001 +7.2508135318E+001 +6.6157989011E-001 -8.1416809458E+000
row 7 : 1600000000.000 +9.5914548536E-001 -1.7737862984E+001 +1.1668774834E-001 +6.5174792956E+001 +1.1751354475E-001 +7.1622743616E+001 +6.6018222718E-001 -8.6633952654E+000

Accepted Answer

Matt Kindig
Matt Kindig on 18 Sep 2012
To read the ASCII file into Matlab:
doc textscan
To convert from magnitude-angle to complex a+bj, just use
Complex= Magnitude.*exp(j*Angle);
  10 Comments
ria
ria on 21 Sep 2012
TEXTSCAN,TEXTREAD,LOAD all were not working because the file contain few comment lines. so I tried this code line after removing the comments.it is working now :
A = load ('filename') %read in file
size(A) %tells the size of the file i.e. 191x9
A(1,:) %prints the first row
A([1],[2 3 4 5 6 7 8 9])
s11mag = A(1,2) %it will assign the magnitude value
%and so on....

Sign in to comment.

More Answers (0)

Categories

Find more on Data Type Conversion in Help Center and File Exchange

Tags

No tags entered yet.

Community Treasure Hunt

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

Start Hunting!