Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to get some symbolic expressions in Mathematica which I would like to paste into my C/MATLAB codes. This can be accomplished nicely by selecting the expression and right-clicking to select Copy as plain-text.

However there is one small issue I have.

Consider the simplest possible case for 2 symbols a and b

In[1]:= c = a*b

Out[1]= a b

How can I tell Mathematica to produce all its output as a*b and not a b Without this, I have to go through the pain of replacing manually all spaces in my C/MATLAB codes with the * espcecially for long expressions.

share|improve this question
Re: converting to MATLAB friendly expression, see this answer – R. M. May 22 '13 at 0:00
For MATLAB, use what rm said. For C, use CForm. – Szabolcs May 22 '13 at 1:09
up vote 12 down vote accepted

The * multiplication operator is rendered in InputForm:

c = a b;

c // InputForm

For producing/exporting strings:

ExportString[c, "Text"]

ToString[c, InputForm]

share|improve this answer
or a b // InputForm ? – cormullion May 22 '13 at 6:40
@cormullion Yes; I guess that might not be apparent to a new user from my answer alone; thanks for pointing that out. – Mr.Wizard May 22 '13 at 6:51

You can set the multiplication symbol in Preferences->Appearance->Numbers->Multiplication

share|improve this answer

Your Answer


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.