How to view/convert to text a Maple script embedded in a mws file - maple

in a textbook, examples on the book companion website are given in Maple, using a .mws file format.
I do not have Maple but I am interested in studying the code of the examples.
I wonder if there is a conversion tool for Linux that allows me to export to text or at least to view the content of the script.
I am aware there exist a free Maple player but from the product description it is not clear if it allows to see the script content or just "play" with the inputs it defines.
I did also try this Maple-to-Python converter, but it's very alpha and it just doesn't work.

The Maple Player should definitely be able to open any .mws file. You won't be able to run commands, but you can at least read the code contained in the file.
Maple itself can export .mws files to text, but other than that, I haven't heard of any other converters for extracting the code from these files.

Related

Merge 2 pdf files and preserve forms

I'd like to merge at least 2 PDF files into one while preserving all the form elements in the original PDFs. The form elements include text fields, radio buttons, check boxes, drop down menus and others. Please have a look at this sample PDF file with forms:
http://foersom.com/net/HowTo/data/OoPdfFormExample.pdf
Now try to merge it with any other arbitrary PDF file.
Can you do it?
EDIT: As for the implementation, I'd ideally prefer a command line solution on a linux plattform using open source tools such as 'ghostscript', or any other tool that you think is appropriate to solve this task.
Of course, everybody is welcome to supply any working solution to this problem, including a coded solution that involves writing a script which makes some API calls to a pdf-processing library. However, I'd suggest to take the path of least resistance first (CMD Solution).
Best Regards
EDIT #2: Well there are indeed several CMD tools that merge PDFs. However, these tools don't seem to, AFAIK, to preserve the forms in the original PDFs! These tools appear to simply just concatenate the printouts of all those PDFs into a single Printout, which is then presented as a single PDF.
Furthermore, If you printout a PDF file with forms into a file, you lose all the forms in it. This clearly not what I'm looking for.
I have found success using pdftk, which is an open-source software that runs on linux and can be called from your terminal.
To concatenate multiple pdfs into one (and preserve form-fillable elements), you can use the following command:
pdftk input1.pdf input2.pdf cat output output-file.pdf

How to read Ansys data files in ParaView?

Anybody knows how to export an Ansys structural data file to ParaView?
It is read that ParaView has an Ansys reader, but it does not work. Errors always come up when loading the *.inp file.
Is there any script to convert .inp files to .vtk?
Thanks
Based on the video from Czech-based SVS FEM s.r.o., I wrote an input file for Ansys Mechanical APDL, that creates a VTK file, which can be opened in ParaView.
In the input file vtk.inp, the user has to specify the argument arg1, for which the nodal values are to be written to the vtk file via the command *get,my_results(j),NODE,n_j,..., p.e.
arg1='S,EQV' ! for equivalent stress or
arg1='TEMP' ! for temperature
For further nodal results, refer to the specifications of the *GET command in the Ansys Commands Reference.
The vtk.inp file should be placed in the current working directory. It is called with the APDL command /input,vtk,inp. In Ansys Mechanical, this command can directly be inserted in the command line. In Ansys Workbench, the command can be pasted in the feature Commands (APDL) under Solution.
The output file output.vtk is written in the same location as the input file.
The code was tested with a structural analysis in Ansys Mechanical APDL 17.2 and Ansys Workbench 17.2. The vtk file was tested with ParaView 5.4.1.
Explanation:
The array e_types_Ansys_to_VTK maps the Ansys element types (p. e. SOLID186) to VTK cell types (see also Ansys Element Types).
Limitations:
The input file is yet limited to write only one scalar parameter result in the vtk file, but it can easily be extended for vector or tensor results as well as for multiple results in one vtk file, following the VTK File Format Specification.
Since Ansys stores nodal results only in the corner nodes, only linear VTK elements are used. There could still be some minor mistakes in the e_types_Ansys_to_VTK map, since I could only test some element types. Please feel free to report any corrections or extensions to the code in the comments.
Here is the link to the source code. Use at your own risk.
In case you would like to export a vtk file directly from Ansys Workbench, a Python result converter was introduced in a Youtube video here. Unfortunately, the source code only appears in the video and is explained in Czech language.
Thus, I typewrote the code from screenshots and made some minor improvements.
You will need two files to install the macro as an Ansys ACT extension:
main.py and vtk.xml.
Place the file vtk.xml in the folder C:\Program Files\ANSYS Inc\v###\Addins\ACT\extensions, where ### is your Ansys version, p.e. 172
Create a new folder vtk in C:\Program Files\ANSYS Inc\v###\Addins\ACT\extensions.
Place the file main.py in the created folder.
Start Ansys Workbench.
Register the path C:\Program Files\ANSYS Inc\v###\Addins\ACT\extensions as additional extension path under Tools > Options > Extensions.
Restart Ansys Workbench, go to Extensions > ACT start page > Extension manager > VTK and load the extension.
In a structural analysis, go to Results, right-click and insert My results. Three inputs have to made by the user:
Under *get,my_results(j),NODE,N,..., , give the desired nodal result according to the Ansys Commands Reference, p.e. S,EQV for equivalent stress.
Under VTF file name, give the full path to the vtk output file to be created, p.e. C:\temp\output.vtk
Under Load step, give the load step number (p.e. 1 for last load step unless not stated otherwise).
For larger models, I experienced that the automatically generated file makeresult.mac is not instantly transferred from the project_pending folder to the actual working directory, thus, causing the macro to throw an error. Maybe, anyone can make a suggestion on how to fix this?
ParaView cannot read .inp structure files (I guess this is the Abaqus file format). You could try to export your files as Nastran (.nas) files, since ParaView has a Nastran reader.

Is there a way to convert/export tracking files (.trc files) from media cybernetics Image Pro Plus to a .mat file type?

I am a biology graduate student trying to export these files so that they can be used with a matlab based automated behavior classification software JAABA. It looks like there is no direct way to save .trc files as .mat (http://www.mediacy.com/imageproplus/specifications). At the very least I would like to figure out a way to read the format of the .trc files so that I could write a script to get them to make sense for JAABA. If anyone is familiar with either of these programs or both, or could simply point to a good way to write an importer (definitely outside of my skill set) I would be very grateful.

How to create reports containing text and figures with MATLAB

I am using a MATLAB script to tune the control system on a machine. When the tuning is complete, I would like a report containing text (especially serial number, date/time and the values determined during tuning) and plots, especially transfer functions.
What do to you recommend?
Whatever solution I use should be compatible with the MATLAB compiler so I can distribute my solution to a team of field engineers.
Ideally the report will be a PDF document.
The MATLAB report generator does not seem to be the right product as it appears that I have to break up my script into little pieces and embed them in the report template. My script contains opportunities for the user to intervene and change values or reject the tune if plots don't look right and my hunch is that this will be difficult if the code runs from the report generator. Also, I fear code structure and maintainability will be lost if the code structure is determined by the requirements of the report template.
Please comment if my assumptions are wrong.
UPDATE
I have now switched to use the MATLAB Report Generator with release r2016b and it is working very well for my compiled code users. Unfortunately it means that colleagues who have a MATLAB licence need to buy the Report Generator too, to use my tools scripted.
As the MATLAB Report Generator's development manager, I am concerned that this question may leave the wrong impression about the Report Generator's capabilities.
For one thing, the Report Generator does not require you to break a script up into little pieces and run them inside a template. You can do this if you choose and in some circumstances, it makes sense, but it is not a requirement. In fact, many Report Generator applications use a MATLAB script or program to interact with a user, generate data in the MATLAB workspace, and as a final step, generate a report from the workspace data.
Moreover, as of the R2014b version, the MATLAB Report Generator comes with a document generation API, called the DOM API, that allows you to embed document generation statements in a MATLAB program. For example, you can programmatically create a document object, add and format text, paragraphs, tables, images, lists, and subdocuments, and output Microsoft Word, HTML, or PDF output, depending on the output type you select. You can even programmatically fill in the blanks in forms that you create, using Word or an HTML editor.
The API runs on Windows, Linux, and Mac platforms and generates Word and HTML output on all three, without the use of Word. On Windows, it uses Word under the hood to produce PDF output from the Word documents that it generates.
The latest release of the MATLAB Report Generator introduces a PowerPoint API with capabilities similar to the DOM API. If you need to include report generation in your MATLAB application, please don't rule out the MATLAB Report Generator based on past impressions. You may be surprised at just how powerful it has become.
I've done this quite a bit. You're right that MATLAB Report Generator is typically not a great solution. #Max suggests the right approach (automating Word through its COM interface), but I'd add a few extra comments and tips, based on my experiences.
Remember that if you're going with this solution, you are depending that your end-users will be running Windows, and have a copy of Office on their machine. If you want to ultimately produce a PDF report, that will need to be Office 2010 or above.
I would bet that you'll find it easier to automate the report generation in Excel rather than Word. Given that you're producing a report from MATLAB, you'll likely be wanting quite a lot of things in tables of numbers, which are easier to lay out in Excel.
If you are going to do it in Word, the easiest way is to first (without MATLAB) create a template .doc/.docx file, which contains any generic text that will be the same for all reports and blank tables for any information. Turn on track changes, and insert empty comments at each point that you will be filling in information. Then within your report creation routine in MATLAB, connect to Word and iterate through each comment, replacing it with whatever data you wish.
If you are learning to automate Excel from MATLAB, this page from the Excel Interop documentation is really helpful. There's an equivalent one for Word.
Unlike #Max, I've never had good results by saving figures to an .emf file and then inserting them. In theory that does preserve editability, but I've never found that valuable. Instead, get the figure looking right (and the right size) in MATLAB, then copy it to the clipboard with print(figHandle, 'dbitmap') and paste to Excel with Worksheet.Range('A1').PasteSpecial.
To save as a PDF, use Workbook.ExportAsFixedFormat('xlTypePDF', pathToOutputFile).
Hope that helps!
I think you are right about the report generator.
In my opinion the fastest/easiest approach would be to generate the report in a html document. For that you just need the figures and write a text file, conversion should be trivial.
Quite similar approach would be to create a Latex file. And then create a pdf from it - though for this you'd need to install latex on your deployed machines.
Lastly you could use the good integration of Java in Matlab. There are several libraries you could use - like this. But I wonder if all the complication will be worth it.
Have you considered driving Microsoft Word through its ActiveX interface? I've done this in compiled Matlab programs and it works well. Look at the Matlab help for actxserver(): The object you want to create is of type Word.Application.
Edit to add: To get figures into the document, save them as .emf files using the -dmeta argument to print(), then add them to the document like this:
WordServer.Selection.InlineShapes.AddPicture(fileName);

Extract .mat data without matlab - tried scilab unsuccessfully

I've downloaded a data set that I am interested in. However, it is in .mat format and I do not have access to Matlab.
I've done some googling and it says I can open it in SciLab.
I tried a few things, but I haven't found any good tutorials on this.
I did
fd = matfile_open("file.mat")
matfile_listvar(fd)
and that prints out the filename without the extension. I tried
var1 = matfile_varreadnext(fd)
and that just gives me "var1 = "
I don't really know how the data is organized. The repository described the data it contains, but not how it is organized.
So, my question is, what am I doing wrong in extracting/viewing this data? I'm not committed to SciLab, if there is a better tool for this I am open to that.
One options is to use Octave, which can read .mat files and run most Matlab .m files. Octave is open source with binaries available for Linux, Mac, and Windows. Inside of Octave you can load the file using:
load file
See Octave's manual section 14.1.3 Simple File I/O for more details.
In Scilab:
loadmatfile('file.mat');
(Source)
I had this same interest a few years back. I used this question as a guide. It uses Python and SciPy. There are options for NumPy and hd5f as well. Another option is to write your own reader for the .mat format in whatever language you need. Here is the link to the mat file format definition.