Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Variable output file name 1

Status
Not open for further replies.

bkal

Structural
Joined
Feb 27, 2003
Messages
275
Location
GB
I have developed a mathcad (V.11) sheet which writes output to an Excel file (Insert > Data > File output). I want to use the sheet to run a number of different cases and write to different Excel files. However, the Excel file name is set once the File output was created. One option is to disable output (by Disable Evaluation), and only activate once the file name is changed manually.

Is there another way to define the ouput file name at the begining of the sheet?

Thanks, bkal
 
I know that you can do what you want if you store your data using the WRITEPRN function instead of using the Excel output object.

You can use the strcat() function along with the num2str() function to stitch together a filename. For example, assuming that the variable v is changing every run and A is your data matrix,

WRITEPRN(strcat(strcat('datafile_',num2str(v)),'.dat') : A

Open up the file in Wordpad to see the format -- you should be able to import this into Excel easily.

In my opinion, Mathcad is severely lacking when it comes to the flexibility of it's string processing and file I/O functions. Maybe this has been improved in v13? Anyone know?

I wonder if it's possible to change the filename of the Excel output object using a VBscript-able object. But that's an entirely different animal altogether.

Another idea would be to embed the Mathcad object into the Excel sheet and use the much more robust Visual Basic for Applications to do all the automation. I think this is possible? Not sure.

HTH,
-Matt


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top