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: Creating new variable name matrix in loop
Replies: 3   Last Post: Jul 28, 2014 11:04 AM

Advanced Search

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

Posts: 4
Registered: 3/24/14
Creating new variable name matrix in loop
Posted: Jul 28, 2014 8:16 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Hi, I have read a few topics that discussed saving new variable names in loops, however i could not find any that resolved my problem.

I am trying to import '.txt' files, a matrix with approx 16 columns. Each time i import them, i want to name each new matrix with a new name, I.e. T1, T2, T3 etc. I can do it manually, however this is time consuming and i have many files in different folders that i will wish to import.

My script follows:

fpath=uigetdir; % user selected path to directory
files=dir([fpath '\*.txt']); % open directory, list files ending txt
files=char(; % list of file names

for i=1:length (m);
% Importing data files

for x=1:length(files); %($$$$$$$$$$$$)

I know that where the line i have marked as '($$$$$$$$)', is wrong, but i am struggling to change the name. Ideally, i would like to name the matrix with a reference to the file name, but i am not too worried about that at the moment.

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.