How can I load information in Matlab into structure?

Dejan VujkovDejan Vujkov Becej, Vojvodina, Serbia

I'm having trouble with loading .txt file in Matlab. The main problem is having not equal rows(connections). First, the file has information about each node in graph. One row has information like this:

1|1|EL_1_BaDfG|4,41|5,1|6,99|8,76|9,27|13,88|14,19|15,91|19,4|21,48...
it means:

id|type|name|connected_to, weight|connected_to, weight| and so on..
And the taks is this:

The structure of the graph should have fields that represent the vertices array of structures , each of which represents a single node . Each of these structures has fields id , type, name , edges and possibly some additional fields that are required due to the specific time ( previousVertexId , weightFromStart ) . Edges is a series of structures that represent one branch each of these structures has fields endVertexId , status and eventual some specific fields to search for ( eg . Weight ) . Status field indicates the state of the switch , which can be 1 or 0. In the start, status is 1

I was trying to use fscanf function, but it only reads one whole line as one string. By using strsplit function i managed to separate those strings with delimiter |. How can I do the same for whole file and after that assign value to each edge(id, type,name,..)?

Best regards,

Dejan

Comments

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion