Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: load column in from text file
Replies: 12   Last Post: Dec 11, 2012 3:47 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Fiboehh

Posts: 8
Registered: 12/15/10
load column in from text file
Posted: Nov 30, 2012 9:56 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Hello I have the following problem:
I have 200 .txt files with the following structure:
0
0
2
3
...
It are kind of random numbers under each other, without a fixed amount. Now I need to do a lot of calculations with these data, but file after file: sequentiel. The results of the calculations have to come in an array, so I can do statistically analysis with the results.
So I read everytime a .txt file and load them in, there the problem occurs. I can't give the data a name to use in the calculations. The loaded in numbers are stored (automatic) in a variable X... which i can't achieve for my calculations.

My code I made by the MATLAB help:
close all
fnames = dir('path\*.txt')
for k = 1 : length(fnames) % all files dir read after each other
fname = fnames(k).name;
eval(['load ' fnames(k).name ' -ascii']);
// Calculations -> B (need the data from the .txt)
//
result(k) = B;
save('Results',result);
end




Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.