Filter löschen
Filter löschen

How to split symbolic output string into multiple lines?

3 Ansichten (letzte 30 Tage)
Sree
Sree am 29 Okt. 2018
Kommentiert: Dyuman Joshi am 3 Jan. 2024
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).

Antworten (1)

Aiswarya
Aiswarya am 3 Jan. 2024
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 Kommentar
Dyuman Joshi
Dyuman Joshi am 3 Jan. 2024
You seem to have misunderstood the question.
The expression given by OP is an output from the code, it's not an input.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Function Creation finden Sie in Help Center und File Exchange

Produkte


Version

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by