Re: Mathematica problem - generate filename automatically



Dave (from the UK) wrote:
Bhuvanesh wrote:

<snip>

Map[(data = Import[#, "Table"]; ListPlot[data, PlotLabel->#])&, filenames]

Is it possible for the PlotLabel to be a be a bit more sophisticated than simply the name of the file. I want a typical PlotLabel to be

"Ref 4A, 1234 MHz, 10\[Degree] to 20\[Degree]"

rather than the just the file name.

<snip>

Sure it can. Mathematica has a large set of string manipulation functions. See

<http://reference.wolfram.com/mathematica/guide/StringManipulation.html>

For instance,

In[1]:= StringJoin["Ref ", StringTake[#, 2], ", ",
StringTake[#, {4, 7}], " MHz, ",
ToString[ToExpression[StringTake[#, {8, 9}]]], "\[Degree] to ",
StringTake[#, {11, 12}], "\[Degree]"] & /@ {"4Af461l00u10.txt",
"4Af461l00u20.txt", "4Af461l00u30.txt"}

Out[1]= {"Ref 4A, 461l MHz, 0\[Degree] to 10\[Degree]", "Ref 4A, 461l MHz, 0\[Degree] to 20\[Degree]", "Ref 4A, 461l MHz, 0\[Degree] to 30\[Degree]"}

(Note that the ASCII string "\[Degree" will display as the degree character when evaluated or pasted in a Mathematica notebook.)

Regards,
--
Jean-Marc
.