Ben Winding
Ben Winding

Reputation: 11787

MATLAB - preventing simplification of equations

Love this site and all the wonderful contributors on it! it has helped me out numerous times, but I can't find what I'm looking for in this instance.

Quick question:

How can I prevent Matlab from automatically 'simplifying' an equation in my matlab m-file?

Example:

Code

syms w l a
V3=(w/(2*l))*(l^2+a^2)

output in command window

V3 =
(w*(a^2 + l^2))/(2*l)

Problem:

The equation V3 is rearranged in its simplest form 'automatically', this makes equations difficult to relate to the referenced equations.

Any help would be much appreciated

Cheers

Upvotes: 3

Views: 1366

Answers (2)

Mahmoud Elzouka
Mahmoud Elzouka

Reputation: 21

You can suppress automatic simplification using

sympref('AbbreviateOutput', false)

Upvotes: 2

Roney Michael
Roney Michael

Reputation: 3994

One way to achieve what you're trying to do would be to use strings and consequentially using the sym() function as illustrated here to convert them to symbolic equations as and when needed.

In doing so, whenever you need to relate to the referenced equations, you can simply compare their string versions which would remain unchanged.

Upvotes: 0

Related Questions