Change viewing format (Console) for the result of an operation made with symbolic variables
Show older comments
Hi.
I'm having problems to manage large results when I make symbolic operations and I view them in Matlab console (understanding problems , because of the massive existence of parentheses in the visualization in console)
Well, I have this output of my symbolic operation (if it's important, I employ pretty( simple(Variable_Result) ) previously to obtain anything in matlab console). In this code , "simple" gives me the best simplification for the symbolic expression, while "pretty" gives me the best console format for that simplified expression output.
Text copy-pasted from console when I use the code above:
L11 am_ix - (s_iz + d_i cos(ai)) (wd_antz sin(ai) + cos(ai) cos(q_i) (wd_anty - qd_i w_antx) - cos(ai) sin(q_i) (wd_antx + qd_i w_anty)) + L12 am_iy + L13 am_iz +
(s_iy + d_i sin(ai)) (wd_antz cos(ai) - cos(q_i) sin(ai) (wd_anty - qd_i w_antx) + sin(ai) sin(q_i) (wd_antx + qd_i w_anty)) +
((s_ix + y_i) (sin(ai) (qd_i + w_antz) + w_anty cos(ai) cos(q_i) - w_antx cos(ai) sin(q_i)) - (s_iy + d_i sin(ai)) (w_antx cos(q_i) + w_anty sin(q_i)))
(sin(ai) (qd_i + w_antz) + w_anty cos(ai) cos(q_i) - w_antx cos(ai) sin(q_i)) - ((s_iz + d_i cos(ai)) (w_antx cos(q_i) + w_anty sin(q_i)) -
(s_ix + y_i) (cos(ai) (qd_i + w_antz) - w_anty cos(q_i) sin(ai) + w_antx sin(ai) sin(q_i))) (cos(ai) (qd_i + w_antz) - w_anty cos(q_i) sin(ai) + w_antx sin(ai) sin(q_i)) - vd_antx cos(q_i) -
vd_anty sin(q_i)
As you can see, it's a hard and slow work, specially if you have "N" expressions like these.. Also I need to create a document later copy-pasting these lines, a I want to make it as fast as possible.
To sum up: if someone knows how to obtain an output in console (result of a symbolic operation) that uses a jerarchic relationship of "markers" (ie. "{,[,(") ) in order not to confuse the user, I would be very pleased.
Thanks in advance.
I wait for your response.
Oscar.
Answers (2)
Walter Roberson
on 5 Mar 2011
0 votes
There is no built-in Matlab routine to do what you are asking.
If I recall correctly, the result from pretty() should be a plain character string rather than something symbolic. You have an unpleasant text-processing task ahead.
Changing the brackets wouldn't be so bad if you were to use a particular bracket as the outermost level, with the brackets cycling through an order as you got deeper and deeper. But that's not usually the way such things are formatted: usually, the deepest brackets are set to a particular bracket type and the bracket types cycle through as you get less deep. That requires that you figure out what your deepest nesting is first before you can assign any symbols. Usually the easiest way to do that is recursion, or recursion curryed to be iterative.
You could also approach the problem from the symbolic level, writing your own pretty() routine. Maybe it could be done in a single MuPad expression, but it would be a lot clearer written as a set of MuPad procedures. How familiar are you with writing your own MuPad procedures?
I could probably work out appropriate Maple code, but some of the Maple operators I would want to use do not translate directly in to MuPad. In particular, I don't have experience translating the way MuPad handles data type testing, and as it is now getting late on a Friday night, I find that I am not presently eager to work it out from the documentation (I don't have MuPad myself.)
Oscar
on 5 Mar 2011
0 votes
Categories
Find more on 3-D Scene Control in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!