How to split symbolic output string into multiple lines?

8 vues (au cours des 30 derniers jours)
Sree
Sree le 29 Oct 2018
Commenté : Dyuman Joshi le 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).

Réponses (1)

Aiswarya
Aiswarya le 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 commentaire
Dyuman Joshi
Dyuman Joshi le 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.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Symbolic Math Toolbox dans Help Center et File Exchange

Produits


Version

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by