How to split symbolic output string into multiple lines?

8 ビュー (過去 30 日間)
Sree
Sree 2018 年 10 月 29 日
コメント済み: Dyuman Joshi 2024 年 1 月 3 日
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 Center および File ExchangeFunction Creation についてさらに検索

製品


リリース

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by