Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

read data from input file in matlab

Status
Not open for further replies.

tarek1984

Junior Member level 1
Joined
Jan 3, 2010
Messages
19
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
cairo
Activity points
1,406
i have a text input file like this


.net N1 A B C
.net N2 D E F
.net N3 G H I
.net N4 J K L
.net N5 M N O
.net N6 A D G H
.net N7 B G J K
.net N8 B J M N
.net N9 A E I O
.net N10 M L F
.net N11 B C E H K
.net N12 E K N
.net N13 F K N
.net N14 C E H
.net N15 H I J M O
.net N16 D H
.net N17 C E
.net N18 I J M N
.net N19 E L
.net N20 H J


and i want to read it in matlab like
N1=[A B C];
N2=[D E F];
N3=[G H I];
N4=[J K L];
N5=[M N O];
N6=[A D G H];
N7=[B G J K];
N8=[B J M N];
N9=[A E I O];
N10=[M L F];
N11=[B C E H K];
N12=[E K N];
N13=[F K N];
N14=[C E H];
N15=[H I J M O];
N16=[D H];
N17=[C E];
N18=[I J M N];
N19=[E L];
N20=[H J];
 

First of all I would like to mention that entering the data into Matlab like you indicated:

and i want to read it in matlab like
N1=[A B C];
N2=[D E F];
N3=[G H I];
N4=[J K L];
N5=[M N O];
N6=[A D G H];
N7=[B G J K];
N8=[B J M N];
N9=[A E I O];
N10=[M L F];
N11=[B C E H K];
N12=[E K N];
N13=[F K N];
N14=[C E H];
N15=[H I J M O];
N16=[D H];
N17=[C E];
N18=[I J M N];
N19=[E L];
N20=[H J];

Will result in nothing more than error messages.

The data can be entered as:

Code:
>> N1 = ['A' 'B' 'C']

N1 =

ABC

>> size(N1)

ans =

     1     3

OR

Code:
>> N1 = ['A'; 'B'; 'C']

N1 =

A
B
C

>> size(N1)

ans =

     3     1

The first results in a 1x3 Array of Characters, the second a 3x1 Array of Characters.

Since, this was not specified I chose the later, I think it is easier to read and should not effect your final application.

I have upoaded the m file, processnetlist.m and the sample data provided by you.

The function can be ran by simply typing processnetlist in the Matlab command window, a dialog box asking you to select the file to be processed opens. Upon select the netlist file, processnetlist processes the fill displaying each line of the file followed by the display of each array created:

...

.net N9 A E I O



N9 =

A
E
I
O

.net N10 M L F



N10 =

M
L
F

.net N11 B C E H K



N11 =

B
C
E
H
K

...

You can test the results by simply typing in the name of one of the arrays created:

>> N11

N11 =

B
C
E
H
K

The function should take care of your requirements and can be modified to fit your future needs.

Contact me if you have any questions.
 

Attachments

  • Matlab PNL Function.zip
    1.4 KB · Views: 79
Last edited:

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top