필터 지우기
필터 지우기

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 (최근 30일)
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

채택된 답변

Matt Kindig
Matt Kindig 2012년 9월 18일
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
ria
ria 2012년 9월 21일
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....

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by