reading from file in matlab and store its content in 2 variables

0

i have input file like image below and it contains adjacency matrix+ one number in first line. so here is the problem that i cant read file in order to set this information in 2 variable one of them stores line 1 and variable 2 stores adjacency matrix. so what I can do about this??

its necessary to mention that adjacency matrix is not in fixed size! Here is a picture of my question: thnx in advanced :)

enter image description here

Arash

Posted 2015-05-24T19:31:32.983

Reputation: 678

i have 1 unrelated question! is there any implementation of independent sets using genetic algorithm in matlab? i cannot find this implementation ! but in C# and java and... thats there. so i appreciate any kind of help! – Arash – 2015-05-24T21:06:41.593

That should probably be a separate question. Do you mean a heuristic for solving the Maximum Independent Set problem? A search yields this. Does that help?

– pyrocrasty – 2015-05-24T21:27:40.307

@pyrocrasty thats good but i need to use genetic algorithm to solve this problem. – Arash – 2015-05-25T04:26:14.597

Answers

1

  1. You can read a matrix from a file into a variable with dlmread

    dat = dlmread('filename.ext', ',')
    
  2. You can use indexing to separate the parts:

    x = data(1, 1)
    table = data(2:end, :)
    

pyrocrasty

Posted 2015-05-24T19:31:32.983

Reputation: 1 332