Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Transfer equations from MathType to Matlab

  1. Apr 18, 2015 #1
    Hi,

    Has anyone tried to paste equations from MathType into Matlab ? I follow every step described here


    No matter what equation I paste, I get following error in Matlab:

    Code (Text):

    |
    Error: The input character is not valid in MATLAB statements or expressions.
     
     
  2. jcsd
  3. Apr 18, 2015 #2

    kreil

    User Avatar
    Gold Member

    Are you pasting into a function file? That looks like an error you would get in the command window.
     
  4. Apr 18, 2015 #3
    No I am not. I thought Matlab deals with the concept the same. Was I wrong?
    An equation definition in command window should be as valid as the same equation annotation in *.m file. (perhaps o_O)
     
  5. Apr 18, 2015 #4

    kreil

    User Avatar
    Gold Member

    Yes they are subtly different in a few ways. Function files (.m files) are reusable, so you can write a function and save it and call it whenever you want. You can't do that with functions you define at the command line (well you can make an anonymous function, but it only lasts as long as you have the variable around...). You can add comments to your code, debug, and do other stuff with function files that you can't do in the command window as well.

    Since these equations you want to write are really comments in a file, entered as LaTeX code, entering them in the command window doesn't really work.
     
  6. Apr 19, 2015 #5
    Well, that's the point. As you know adding a % character in the beginning of line in MATLAB, will make that entire line as a comment and will be ignored for interpretation purpose. How above sample code is suppose to define me a function where the function definition line is already commented out? That's my question I am afraid.
     
  7. Apr 19, 2015 #6

    kreil

    User Avatar
    Gold Member

    When you publish the file it turns the comments into HTML, so the equation renders and displays. The m file is just the source file that is published to produce the final output
     
  8. Apr 19, 2015 #7
    hmmm. I see.

    Thanks for all the replies Kreil.
     
  9. Apr 19, 2015 #8

    kreil

    User Avatar
    Gold Member

    Just to be clear, you can't import an equation into MATLAB as a usable function from math type. You'll need to do that manually by writing the expression out (or use an anonymous function). The functionality described above allows you to display the same equation as an annotation.

    Please let me know if that answers your question
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Transfer equations from MathType to Matlab
Loading...