The Math Forum

Search All of the Math Forum:

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

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

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

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 ]

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:
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;

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

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.