MATLAB: How to add tables or equations to a problem description in MATLAB Grader? Can I use LaTeX

distance_learningequationlatexmatlab gradermatlab_grader

Is there a way to add tables or mathematical equations in a problem description in MATLAB Grader? Or should I just insert an image?

Best Answer

Yes, you can add formatted mathematical equations and tables using the Insert LaTeX icon.
Clicking on it opens a new window where you can build your equation or table using LaTeX, with a preview of the result displayed below.
You can also create inline equations by starting and ending your LaTeX expression with “$”.
What if I don’t know LaTeX?
The problem description of a MATLAB Grader problem is similar to text blocks in live scripts. Build your expression interactively in a live script first. Then, select your expression, rt click on it, and select “Copy as LaTeX”. Paste the LaTex code into the LaTeX editor in MATLAB Grader.
What if my existing LaTeX expression is not working?
MATLAB does not support all LaTeX libraries. Unsupported commands will appear red in the editor (for example, table).
To ensure compatibility, it is recommended you build your expressions in a live script first using the interactive equation editor. However, for existing LaTeX expressions, you can use the interactive editor to find a supported feature to use in your expression (for example, matrix instead of table).
To get the equivalent LaTeX code, select the expression, rt click and select Copy as LaTeX.
Paste to see the supported expression.
\left\lbrack \begin{array}{cc}
& \\
& \\
&
\end{array}\right\rbrack
Replace the unsupported LaTeX in your expression with this code. In this example, that means wrapping the table entries with {array} instead of {table}. Once you have the LaTex formatted as you want, add your expression to the problem description.
\begin{array}{ll}
Time & f(t)=sin(t) \\
-\pi/4 & sin(-\pi/4) \\
0 & sin(0) \\
\pi/4 & sin(\pi/4)
\end{array}
The final table used in this example looks like this:
You can also learn about inserting equations into live scripts in Chapter 3 of Teaching with MATLAB, a free, self-paced training designed for instructors.