Borrar filtros
Borrar filtros

How to split symbolic output string into multiple lines?

3 visualizaciones (últimos 30 días)
Sree
Sree el 29 de Oct. de 2018
Comentada: Dyuman Joshi el 3 de En. de 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).

Respuestas (1)

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

Iniciar sesión para comentar.

Categorías

Más información sobre Function Creation en Help Center y File Exchange.

Productos


Versión

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by