How to split symbolic output string into multiple lines?

8 次查看(过去 30 天)
I am using the Symbolic Toolbox to solve a simple ODE that yields the following very long one-liner equation: 25*exp(-alpha*t) + exp(-alpha*t)*(400*heaviside(t - 5)*exp(alpha*t) - 25*heaviside(t) + 2000*heaviside(t - 10)*exp(alpha*t) - 2400*heaviside(t - 12)*exp(alpha*t) - 400*heaviside(t - 5)*exp(5*alpha) - 2000*heaviside(t - 10)*exp(10*alpha) + 2400*heaviside(t - 12)*exp(12*alpha) + 25*exp(alpha*t)*heaviside(t) + (80*heaviside(t))/alpha + (80*exp(alpha*t)*heaviside(t)*(alpha*t - 1))/alpha - (80*heaviside(t - 5)*exp(alpha*t)*(alpha*t - 1))/alpha - (200*heaviside(t - 10)*exp(alpha*t)*(alpha*t - 1))/alpha + (200*heaviside(t - 12)*exp(alpha*t)*(alpha*t - 1))/alpha + (80*heaviside(t - 5)*exp(5*alpha)*(5*alpha - 1))/alpha + (200*heaviside(t - 10)*exp(10*alpha)*(10*alpha - 1))/alpha - (200*heaviside(t - 12)*exp(12*alpha)*(12*alpha - 1))/alpha)
I would like to first split the equation into multiple lines, as shown above. (In the command window, the same equation appears in one long line).
Then I'd like to convert the multi-line output to Tex or Latex for insertion into a Word document (with MathType).

回答(1 个)

Aiswarya
Aiswarya 2024-1-3
Hi Sree,
You can use ellipsis(…) to split long equations into multiple lines as follows :
This can be used for any statement.
For getting the LaTeX format, since this a symbolic equation you can use the 'latex' function (https://www.mathworks.com/help/symbolic/sym.latex.html). You can save your equation in a variable and use 'latex()' on it.
  1 个评论
Dyuman Joshi
Dyuman Joshi 2024-1-3
You seem to have misunderstood the question.
The expression given by OP is an output from the code, it's not an input.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Symbolic Math Toolbox 的更多信息

产品


版本

R2017b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by