How to load a package in Maple? - maple

I want to use a package called "ESC" elliptic surface calculator that can be uploaded with Maple.
The instructions from the creator are:
Save as a text file with character encoding ISO-8859-1 (ISO Latin 1)
and load within Maple using "read" command).
I have problem with uploading to Maple and saving with this encoding. Can anybody say the exact upload command with details and how to save text with this encoding?
Here is the package page: http://c-faculty.chuo-u.ac.jp/~kuwata/2012-13/Maple_resources/ESC.mpl
I use Windows 8.1 and Maple 18. Thanks!

On the webpage, just right click on the source code file and then click save as a text file.
After that, open maple work sheet and read the file ESC.mpl.txt, like this
restart:
read("C:/tcdata/ESC.mpl.txt") # I have save the file in a folder named `tcdata` in drive C.
Once the file is loaded/read in maple, you can do whatever you are suppose to do. I tried these, to check whether the source code is working or not.
ESC();
elliptic_surface(1,1,1,1,1);
Apparently, the source file has been read and is working properly.

Related

Persian font encoding in m-files on Matlab [duplicate]

I'd like to use Unicode characters in comments in a MATLAB source file. This seems to work when I write the text; however, if I close the file and reload it, "unusual" characters have been turned into question marks. I guess MATLAB is saving the file as ASCII.
Is there any way to tell MATLAB to use UTF-8 instead?
According to http://www.mathworks.de/matlabcentral/newsreader/view_thread/238995
feature('DefaultCharacterSet', 'UTF8')
will change the encoding to UTF-8. You can put the line above in your startup.m file.
How the MATLAB Process Uses Locale Settings shows how to set the encoding for different platforms. Use
feature('DefaultCharacterSet')
You can read more about this undocumented function here. See also this Matlab Central thread for other options.
Mac OSX only!
As I found solution which worked in my case I want to share it.
Mathworks advises here to use slCharacterEncoding(encoding) in order to change the encoding as desired, but for the OSX this does not solve the issue exactly as the feature('DefaultCharacterSet') in accepted answer does not do it. What helped me to get the UTF-8 encoding set for opening and saving .m files was the following link on MATLAB answers:
https://www.mathworks.com/matlabcentral/answers/12422-macosx-encoding-problem
Matlab seems to ignore any value set in slCharacterEncoding(encoding) or feature('DefaultCharacterSet') but uses region set in System Preferences -> Language & Region. After checking which region is selected in our case then it is possible to define the actual encoding in the hidden configuration file in
$matlabroot/bin/lcdata.xml
This directory can be opened by getting to the Applications and after right click on Matlab by selecting Show Package Contents as on screenshot (here in German)
For example for German default ISO-8859-1 it is possible to adjust it by changing the respective line in the file lcdata.xml:
<locale name="de_DE" encoding="ISO-8859-1" xpg_name="de_DE.ISO8859-1">
to:
<locale name="de_DE" encoding="UTF-8" xpg_name="de_DE.UTF-8">
If the region which is selected is not present in the lcdata.xml file this will not work.
Hope this helps!
The solution provided here worked for me on Windows with R2018a.
In case link doesn't work: the idea is to use file matlabroot/bin/lcdata.xml to configure an alias for encoding name (some explanation can be found in this very file in the comments):
<codeset>
<encoding name="UTF-8">
<encoding_alias name="windows-1252" />
</encoding>
</codeset>
You would use your own value instead of windows-1252, currently used encoding can be obtained by running feature('locale').
Although, if you use Unicode characters in help comments, the help browser does not recognize them, as well as console window output.
For Mac OS users, Jendker's solution really helps!!! Thanks a lot first.
Recap here.
Check the default language in Matlab by typing in the command window getenv('LANG'). Mine returned en_US.ISO8859-1.
In the Application directory find Matlab, show its package contents. Go to bin, open lcdata.xml as an administrator, locate the corresponding xpg_name, in my case en_US.ISO8859-1. Change encoding in the same line to UTF-8. Save it.
Restart Matlab, and it's all done!

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

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.

load unix executable file to ascii

I am simply trying to load ascii files with two columns of data (spectral data).
They were saved originally as .asc.
I need to open and edit them using text editor before I can load them into Matlab to erase the headers, but some of them somehow got converted to unix executable foramt with the .asc extension. And others are plain text docs also with the same extension. I have no idea why they got saved with the same extension and with my same manipulation as different kind formats.
When I use the load command in Matlab, the plain text docs load normally as expected but the ones saved as unix executable kinds give me this error:
Error using load Unable to read file filename.asc: No such file or
directory.
How can I either resave them (still with the same extension) or otherwise load them to be read by Matlab as standard two column data matrixes?
Thanks!
If these are truly plain text files, try renaming the file from xxx.asc to xxx.txt. Then, see if you are able to edit them as desired.

How to load a matlab file (.mat) in windows if it was originally saved in UNIX

I'm trying to open a .mat file in the windows environment but it is failing. It was created in a Unix environment. Also note that this file was first put in a .tar file first, ftp via binary method. The file opens in Unix and I don't think it was corrupted in any way.
The *.mat file format is platform agnostic. The OS does not matter.
There are a number of variants of the *.mat file which have been used, and older versions cannot always read formats saved with newer versions. You can save to an older version using flags available in the save command. These formats have been updated as the Matlab feature set has demanded a more flexible file format, and as other technologies have advanced, most notably HDF5 in the recent version.
Finally, the save command supports an ASCII formatted option. I suspect this is your current problem, based on your comment regarding the error message received.
To address your current problem:
First, check to see if the file is an ASCII file. The easiest way is to simply open it in notepat, wordpad, or even the matlab editor. If the file is text, then this becomes a file parsing problem, and the appropriate use of fscanf shoudl fix the problem.
If the file is actually a binary *.mat file then you probably have a Matlab version incompatability. Yuo can either go back to the source unix environment and save to an older version (eg save .... -v7) or update the Matlab version of the reading computer.

Unicode characters in MATLAB source files

I'd like to use Unicode characters in comments in a MATLAB source file. This seems to work when I write the text; however, if I close the file and reload it, "unusual" characters have been turned into question marks. I guess MATLAB is saving the file as ASCII.
Is there any way to tell MATLAB to use UTF-8 instead?
According to http://www.mathworks.de/matlabcentral/newsreader/view_thread/238995
feature('DefaultCharacterSet', 'UTF8')
will change the encoding to UTF-8. You can put the line above in your startup.m file.
How the MATLAB Process Uses Locale Settings shows how to set the encoding for different platforms. Use
feature('DefaultCharacterSet')
You can read more about this undocumented function here. See also this Matlab Central thread for other options.
Mac OSX only!
As I found solution which worked in my case I want to share it.
Mathworks advises here to use slCharacterEncoding(encoding) in order to change the encoding as desired, but for the OSX this does not solve the issue exactly as the feature('DefaultCharacterSet') in accepted answer does not do it. What helped me to get the UTF-8 encoding set for opening and saving .m files was the following link on MATLAB answers:
https://www.mathworks.com/matlabcentral/answers/12422-macosx-encoding-problem
Matlab seems to ignore any value set in slCharacterEncoding(encoding) or feature('DefaultCharacterSet') but uses region set in System Preferences -> Language & Region. After checking which region is selected in our case then it is possible to define the actual encoding in the hidden configuration file in
$matlabroot/bin/lcdata.xml
This directory can be opened by getting to the Applications and after right click on Matlab by selecting Show Package Contents as on screenshot (here in German)
For example for German default ISO-8859-1 it is possible to adjust it by changing the respective line in the file lcdata.xml:
<locale name="de_DE" encoding="ISO-8859-1" xpg_name="de_DE.ISO8859-1">
to:
<locale name="de_DE" encoding="UTF-8" xpg_name="de_DE.UTF-8">
If the region which is selected is not present in the lcdata.xml file this will not work.
Hope this helps!
The solution provided here worked for me on Windows with R2018a.
In case link doesn't work: the idea is to use file matlabroot/bin/lcdata.xml to configure an alias for encoding name (some explanation can be found in this very file in the comments):
<codeset>
<encoding name="UTF-8">
<encoding_alias name="windows-1252" />
</encoding>
</codeset>
You would use your own value instead of windows-1252, currently used encoding can be obtained by running feature('locale').
Although, if you use Unicode characters in help comments, the help browser does not recognize them, as well as console window output.
For Mac OS users, Jendker's solution really helps!!! Thanks a lot first.
Recap here.
Check the default language in Matlab by typing in the command window getenv('LANG'). Mine returned en_US.ISO8859-1.
In the Application directory find Matlab, show its package contents. Go to bin, open lcdata.xml as an administrator, locate the corresponding xpg_name, in my case en_US.ISO8859-1. Change encoding in the same line to UTF-8. Save it.
Restart Matlab, and it's all done!