Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.
  1. Is there a command window and an editor in Mathematica 8 similar to those in Matlab? In Mathematica GUI mode, all I saw is write code and run it in the same notebook.
  2. In my Ubuntu terminal, I successfully started Mathematica by ./math (which is the only way I know by the way and I would also like to know what options are available when starting up).

    When I simply copy and paste the code from Heike , nothing new appears, and when I copy and paste the code of Daniel, it works. Wonder why?

  3. Is it correct that there are exactly two ways of running Mathematica code: in a notebook, and in a Mathematica session running in my Linux terminal?

    Are the notebook way and the GUI mode the same thing?

    What does "kernel" mean in Mathematica?

    What are some basic concepts and common sense of running Mathematica?

share|improve this question
8  
You might want to start reading some documentation in the built-in help system or it's online mirror. This is a good start in this case. –  Sjoerd C. de Vries Mar 13 '12 at 23:20
1  
mathematica.stackexchange.com/a/259/73 –  CHM Mar 14 '12 at 1:25
add comment

3 Answers

up vote 8 down vote accepted

Heike's code produces a graphics output. So if you run it inside a raw kernel (which is what the math command does on linux), it won't display any graphics. Instead you'll see something like --Graphics-- on your screen. To actually display the output, you'll need to load the JavaGraphics package as <<JavaGraphics` before the plot command (this needs to be done only once per session).

Jens has more on running Mathematica without a front-end. Brett Champion also notes the following:

When using JavaGraphics`, graphics are rendered by a child front end and converted to a bitmap format. So most new features of graphics are supported. The exception is that if there are interactive aspects to the graphic (tooltips, mouse-overs, Dynamics), they will effectively be ignored. Visualization functions sometimes have problems since in order for them to work correctly, they have to handle Show and DisplayFunction just right. If you do run across problems with a visualization function when using JavaGraphics` , please file it as a bug.

As for the rest of the questions, I'll refer you to the official documentation that Sjoerd shared, as there is no need to duplicate information.

share|improve this answer
1  
I think if one needs to work with the terminal, to see graphics one could Export them to png and use any image viewer. –  FJRA Mar 14 '12 at 0:17
2  
That warning is not accurate. When using JavaGraphics` graphics are rendered by a child front end and converted to a bitmap format. So most new features of graphics are supported. The exception is that if there are interactive aspects to the graphic (tooltips, mouse-overs, Dynamics), they will effectively be ignored. Visualization functions sometimes have problems since in order for them to work correctly, they have to handle Show and DisplayFunction just right. If you do run across problems with a visualization function when using JavaGraphics` , please file it as a bug. –  Brett Champion Mar 14 '12 at 3:21
    
@R.M Thanks for pointing out that JavaGraphics` now supports all version 8 graphics. I must have tested it on version 7 when I saw that there were missing features. I've changed my statement on the web page you linked. –  Jens Apr 3 '12 at 15:13
    
@Jens Brett deserves the credit for that (I think it was also discussed in chat by a few people). My apologies — I should've pinged you to let you know that it has changed :) –  rm -rf Apr 3 '12 at 15:19
add comment

You can start a standalone kernel which pretty much behaves like a very rudimentary command line window. The normal FrontEnd (the "notebook interface") is an extra program which basically is the standard editor but also allows to send pieces of code to an (or several) connected kernels. For the communication these two programs actually don't use the command line interface you see when starting a standalone kernel but a more structured protocol called MathLink.

A notebook file opened in the FrontEnd (= the notebook interface) behaves very similar to a matlab script file with cell mode enabled, where you also can send the code within a "cell" to the kernel. The main difference is that the output will be shown in the command line window (and needs to be saved in an extra file if you want to keep it) in matlab but will be shown in the notebook right below the evaluated cell in Mathematica and become part of that notebook file. Another big difference is that the Mathematica FrontEnd is really a standalone program and you can quit the kernel and start another one from within the FrontEnd, whereas to restart the "matlab kernel" you'll need to restart the matlab graphical user interface.

Especially when you edit .m-package files (not the .nb-notebook files) with the frontend what it does technically is very similar to the matlab editor: in both cases there is some "markup" code inserted into the text file which the editor uses to structure and format the text to show. The notebook file format is somewhat more involved and has AFAIK no real counterpart in matlab, what probably comes closest (but not really) are the matlab "notebook files" which can be used to prepare your matlab code for publishing with html- and latex-formatted comments, but a Mathematica notebook is like a WYSIWYG version of that which will additionally allows for interactive content (see Manipulate and Dynamic).

By using the comand line interface or the mathlink protocol (along with some of the higher level variants like JLink or NETLink) there are in fact infinitely many possibilities to run Mathematica code, there is e.g. a Mathematica mode for emacs or webMathematica, which lets you embedded Mathematica code in html to be executed on a webserver. If you are looking for an interface that is more like what you are used to from matlab you could also have a look at Wolfram Workbench, which is basically a Mathematica plugin for the eclipse IDE.

But I think especially for a beginner it is much better to get familiar with the normal notebook interface, otherwise you'll stumble across peculiarites like the graphics output every now and then. Just because the notebook interface is different from what you have seen before doesn't mean it's bad: in fact I think that for a great many use cases the concept of the notebook interface has big advantages and only by making use of these you'll get the most out of Mathematica's possibilities. If you don't engage in the "Mathematica way" and use it just like matlab with a different syntax you can't expect to gain very much except of wondering about oddities.

A different interface (like the workbench or the command line interface) only seems to make sense when you have very special demands, e.g. you are writing more involved packages for others to use or you need to run large jobs using a job queuing/scheduling system.

share|improve this answer
add comment

When you see Mathematica for the first time you try to fit it into the mental model of how software works. While doing that, one of the first things people do is to try to classify Mathematica as a GUI program or as a command line program. Mathematica is unique in that it is both at the same time. For example, commands can take graphics as arguments.

Mathematica has two separate components: The Kernel and the Front End. When you run Mathematica inside a terminal window you are only running the kernel. The kernel let's you do any calculation but you will be lacking the interactive features.

share|improve this answer
    
Thanks! Isn't Matlab the same way as you described? –  Tim Mar 14 '12 at 14:11
    
@Tim, Mathematica does not have a MATLAB like GUI, with windows showing files in the current directory or local variables. Most of the stuff, like plotting, happens inside the notebook, and not in separate windows like in MATLAB. –  Adal Mar 14 '12 at 20:09
    
@Tim does Matlab allow you to copy and paste a graphic directly into a function as an argument? –  Mr.Wizard Mar 15 '12 at 10:02
    
@Mr.Wizard: I think every graph in matlab has a handle, so it is possible to process that handle. Is it? –  Tim Mar 15 '12 at 10:51
    
@Tim sorry, I don't use Matlab; I was curious myself. –  Mr.Wizard Mar 15 '12 at 11:04
show 3 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.