Mathematica problem - generate filename automatically
- From: "Dave (from the UK)" <see-my-signature@xxxxxxxxxxxxx>
- Date: Wed, 19 Sep 2007 20:21:35 +0100
I have a load of text files for which I'd like to plot the data in them (its just an x and a y pair on the same line). The following works
data=Import["somefile.txt", "Table"]
ListPlot[data,PlotLabel->" Ref 4A, 461 MHz, 10 to 20 deg"]
But there are lots of files and it would be tedious to do this manually. I would like to generate the filenames in Mathematica, then use the Import command to read the data from these dynamically generated filenames.
The file names consist of
i) A two letter reference (ref=4A, 5C or 5D)
ii) Lower case letter f
iii) 3 or 4 digit integer (freq=461, 767, 1234 or 4554)
iv) the letter 'l'
v) A number n1 which is either 00, 10, 20, 30 or 80
vi) A number n2 10, 20, ..90
I could easily create 4 lists
ref={4A, 5C or 5D}
freq={461, 767, 1234 or 4554}
n1={00, 10, 20, 30, 40, 50, 60, 70, 80}
n2={10, 20, 30, 40, 50, 60, 70, 80, 90}
But how can I best combine those lists, so it creates a file name?
The following are some example file names,
4Af461l00u10.txt (ref 4A, 461 MHz, 0 to 10 degrees)
4Af461l10u20.txt (ref 4A, 461 MHz, 10 to 10 degrees)
4Af461l20u30.txt (ref 4A, 461 MHz, 20 to 30 degrees)
4Af461l30u40.txt etc ctc
4Af461l40u50.txt
4Af461l50u60.txt
4Af461l60u70.txt
4Af461l70u80.txt
4Af461l80u90.txt
5Cf461l00u10.txt
5Cf461l10u20.txt
5Cf461l20u30.txt
5Cf461l30u40.txt (ref 5C, 461 MHz, 30 to 40 degrees)
5Cf461l40u50.txt
How can I best generate the file names? I wish to be able to use the numbers/reference in the PlotLabel too. i.e. if the file name has a reference of 4A and is data at 461 MHz between 30 and 40 degrees, then that needs to go into the plot lable.
I'm tempted to write a C program to generate the Mathematica commands, but I'm sure it must be possible to do this in Mathematica - I just know C better!
Any help appreciated.
--
Dave (from the UK)
Please note my email address changes periodically to avoid spam.
It is always of the form: month-year@xxxxxxxxxxxx
Hitting reply will work for a few months only - later set it manually.
http://chessdb.sourceforge.net/ - a Free open-source Chess Database
.
- Follow-Ups:
- Re: Mathematica problem - generate filename automatically
- From: Bhuvanesh
- Re: Mathematica problem - generate filename automatically
- Prev by Date: Re: mupad / DifferentialGeometry
- Next by Date: Re: mupad / DifferentialGeometry
- Previous by thread: mike lalonde sudbury ontario
- Next by thread: Re: Mathematica problem - generate filename automatically
- Index(es):
Relevant Pages
|
Loading