Filter löschen
Filter löschen

"simplify" doesn't work properly

29 Ansichten (letzte 30 Tage)
ercan duzgun
ercan duzgun am 15 Aug. 2018
Dear Matlab users;
I have a problem when I use symbolic toolbox. When it gives the result in symbolic, even though I use simplify comment, it doesn't work properly as I want it to be.
I will give a similar example here, since the actual one is a bit long:
2*(sin(x)*1/2+cos(x)*1/2)
When I calculate the result myself by hand, I get;
sin(x)+cos(x) .
But MATLAB gives the result as I written above.
How can I fix this?
Thanks in advance.
  1 Kommentar
Christopher Creutzig
Christopher Creutzig am 3 Dez. 2018
It would probably help to give an actual working example of your problem.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Star Strider
Star Strider am 15 Aug. 2018
Bearbeitet: Star Strider am 15 Aug. 2018
Choosing the correct function is important. Without knowing your actual expression (so I do not know if this is appropriate for it), expand or isolate rather than simplify may be most appropriate:
syms x
Eq = 2*(sin(x)*1/2+cos(x)*1/2);
R = expand(Eq)
R =
cos(x) + sin(x)
  1 Kommentar
Christopher Creutzig
Christopher Creutzig am 3 Dez. 2018
For this input, Eq is already in the expected form.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

ercan duzgun
ercan duzgun am 15 Aug. 2018
Well, as I find out: the vpa comment fix this problem better.
  1 Kommentar
Star Strider
Star Strider am 15 Aug. 2018
The vpa function is certainly another option.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Symbolic Math Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by