Howdy, Stranger!

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

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

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.