I want to run the Mathematica file with some extension, like '.m'. But, I don't know, how can I run the code. Please, guide me.
1 Answers
If a file has the extension .m, then I assume you are trying to load a package into your notebook. This can be achieved by calling the package (say called PackageName.m) into your own notebook by doing the following:
You can type into your opening like
<<PackageName`, which uses the backtick symbol`. It is probably at the left hand side of your keyboard.Alternatively, this is a shortcut for the MMA function
Get, given in the documentation here. The first example has the above notation I was talking about. ThenGet["PackageName.m"]would work.
Here is a screenshot so you can see the backtick in action.
- 124,525
- 11
- 401
- 574
- 135
- 13
-
Thank you so much for your kind response.
Are you talking about this symbol '' ~ ''. I just type "<<PackageName(~)" in the notebook, but it does not work. I also type ''<<~'', it also does not work. Sorry to say, I am facing difficulty to learn from the example. – MMS Mar 17 '19 at 14:13 -
I have added a screenshot. You are on the right key I think, but instead you have held-down shift instead. It's a tricky key to type, but my screenshot should help you. – Brad Mar 17 '19 at 14:17
-
1It's tricky but: enclose any code that has backticks in double backticks. I did this for your answer. – J. M.'s missing motivation Mar 17 '19 at 14:23
-
@J.M.isslightlypensive that's one of the worst things that to look at - 5 backticks is far too many. Thanks for your help JM. – Brad Mar 17 '19 at 14:24
-
Now, I followed your suggestions and type. But, I found the error. I am pasting here both input and output which I got. In[8]:= <<PackageName` Get["PackageName.m"]
During evaluation of In[8]:= Get::noopen: Cannot open PackageName`.
Out[8]= $Failed
During evaluation of In[8]:= Get::noopen: Cannot open PackageName.m.
Out[9]= $Failed
– MMS Mar 17 '19 at 15:27 -
@MisbahShahzadi - unless you've called your package
PackageNamethen Mathematica won't find it. You need to search for your own package name which you have on your system. A key point is to make sure that the package is installed in the correct directory. This either could come with a file distributed with your package, which will automatically install it in the correct location, or you'll need to do it manually. A buzzword might be$UserBaseDirectory. This post may be useful: https://mathematica.stackexchange.com/questions/669/how-to-install-packages – Brad Mar 17 '19 at 15:30 -
Thank you so much. I tried with the same procedure as mentioned in the link but get syntax error. How can I paste here screen shot?, so you can see the error. – MMS Mar 18 '19 at 18:21
-
1Screenshots aren't much use. If you have to, post your screenshot and more importantly, your code as an edit in your original post. – Brad Mar 18 '19 at 18:25

Get. – Henrik Schumacher Mar 17 '19 at 12:25Getfunction. That's all. – Szabolcs Mar 18 '19 at 12:12*.mfile, it is clear from the contents of the file that it is not generated by Mathematica, and is not of Wolfram syntax (hence the close vote). Perhaps the*.mfile is from Matlab, as I recall its vector syntax being[v1, v2, ...]that complies with said file. – István Zachar Apr 05 '19 at 16:38