From: Samantha Cafferky on 7 Jun 2010 12:40 I'm fairly new to Matlab, and I'm converting some .dat files to .mat files. I have over 1000 of them to convert, and doing it one by one is a slow process. can anyone help me with a small program that might do them all at once, or at least more than one at a time? The commands I use right now are these: >> cd C:\GRABS100526 >> [data,time,note] = readSeg2('*.dat') >> save May26_* >> clear Line 1 picks the directory, I only have to do this once or set the directory in another way. (But you knew that.) Line 2 opens the .dat file (whatever the number may be, represented with the *), brings up the data for me to see. "readSeg2" is a .m file that they created to open up these types of .dat files. Line 3 saves it into the same directory under the slightly different name and as a .mat file (e.g., "May26_2431", the * represents the same number as in Line 2). Line 4 clears the workspace so that I don't have all these .dat files getting compiled into one .mat file. I want each .dat file to have a separate, collating .mat file. Thank you for anyone who can help! Sam
From: Steven Lord on 7 Jun 2010 13:04 "Samantha Cafferky" <soccer.sam.14(a)comcast.net> wrote in message news:huj7d4$b0h$1(a)fred.mathworks.com... > I'm fairly new to Matlab, and I'm converting some .dat files to .mat > files. I have over 1000 of them to convert, and doing it one by one is a > slow process. can anyone help me with a small program that might do them > all at once, or at least more than one at a time? *snip* See Q4.12 in the newsgroup FAQ; it describes a couple of approaches you can use to process a sequence of files. Turn your "one-at-a-time" code into a function that accepts the name of the file to process and then call it once for each file. You'll probably want to use some of the string manipulation functions to adjust the filename; see HELP STRFUN for a list of a few such functions that you can use. -- Steve Lord slord(a)mathworks.com comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ To contact Technical Support use the Contact Us link on http://www.mathworks.com
|
Pages: 1 Prev: Newbie, trying to batch jobs Next: Need help with GUI code |