MATLAB LOADING DATA FROM A .TXT FILE - Programmers Heaven

Howdy, Stranger!

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

Categories

MATLAB LOADING DATA FROM A .TXT FILE

rcbarrenechearcbarrenechea Posts: 1Member
MATLAB LOADING DATA FROM A .TXT FILE?

Please I need some help with this to finish my thesis.

I tried to load the solution.txt file in MATLAB, but i have been
unable to do it because it sais that there is a format problem
with the first rows, however i only need to load the rows 6 to 9 from the file
wich have a recognazible format and can be loaded with the textread function

The solution.txt file has the following data:

OBJECTIVE FUNCTION VALUE

1) 3942307.

VARIABLE VALUE REDUCED COST
UI001 0.02 -96876.960938
UI002 0.06 359612.000000
UI003 0.01 392966.000000
UI004 0.05 392966.000000

ROW SLACK OR SURPLUS DUAL PRICES
2) 0.000000 -30.976025


I only need to load rows 6 to 9, without changing in any way the solution.txt file.
The data i need would be:

UI001 0.02 -96876.960938
UI002 0.06 359612.000000
UI003 0.01 392966.000000
UI004 0.05 392966.000000

Could someone please tell me what function can i use to load the solution.txt file
but delimited only to the rows 6 to 9?

Thank you

Comments

  • jjasso5jjasso5 Posts: 41Member
    use the parameter 'headerLines' within the textscan function.

    For example:

    data1 = textscan(fopen(...), '%f %f %f', 'headerLines', 6)
    The '6' means to skip the first 6 lines.



    Learn Matlab here!
    http://www.matrixlab-examples.com
  • lalaounisjacoblalaounisjacob Posts: 1Member
    Hello

    I have a problem in matlab. I would like to read a .txt file like this
    5) 3 368ms
    6) 1
    7) 6
    8) 1
    9) 4
    10) 1 *
    11) 6 *
    12) 1 *
    13) 2
    14) 1
    15) 6 410ms


    the problem is that the data i want to read and write them in another file (only the third column) and in the third column where there is a space to write 0 and where is * to put -1 and from 410ms to keep only 410, the number.

    Please help,
    I am trying one week now

Sign In or Register to comment.