"Diego Zegarra" <diegozbb@gmail.com> wrote in message <gd08nd$dsr$1@fred.mathworks.com>...
> Hey guys,
> I have .txt files that have the following structure and they all are different.
>
> 12
> 120
>
> 81 79 85 97 91 75 60 98 79 56 91 82
> ...
> ..
> .
> 74 74 64 86 90 59 98 74 53 56 81 58
> 50 90 76 68 53 57 60 73 72 62 99 55
>
> 69 74 75 62 76 55 67 55 78 96 69 79 69 97 53 59 72 ... 56
> ...
> ..
> .
> 89 78 91 72 59 52 92 96 95 95 74 98 99 68 55 69 66 ... 76
>
> So let me explain what this means. First the 12 and 120 means 12 machines (m) and 120 jobs (n). I want to be able to save this as a variable.
>
> Then the next block shows a number of jobs times number of machines matrix which I also want to save as a different variable.
>
> After that there are m blocks of data (12 in this case) with a matrix of nxn. I want to be able to save each of these blocks in a variable each.
>
> All my files will have a different number of machines and jobs so I want MATLAB to be able to read this automatically.
Maybe txt2mat (file exchange) can help you with this; you could simply type
A = txt2mat('C:\filename.txt');
to get in all the data into one larger matrix (padded with NaNs where no data is available) and then examine this matrix to find out the indices of interest.
Hth,
Andres
"Andres " <rantore@werb.deNoRs> wrote in message <gd0abt$1ro$1@fred.mathworks.com>...
> [..]
> A = txt2mat('C:\filename.txt');
> [..]
A small correction: rather tell txt2mat the number of header lines (zero, I guess), to ensure that the first two lines with the single numbers are imported to A as well:
A = txt2mat('C:\filename.txt',0);
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for
all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content.
Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available
via MATLAB Central.
Read the complete Terms prior to use.