A way to get MatLab to solve inequality from left to right and not by order of operation?

4 Ansichten (letzte 30 Tage)
I have this equation that I want to solve from left to right and not by order of operation, and I was wondering if there was a command to stop MatLab from automatically solving it by order of operation?
-3+1*10=8+1/3
when I solve each side separately each side should be -20 for left side and 3 for right side. Any help would be appreciated.

Antworten (2)

sixwwwwww
sixwwwwww am 13 Okt. 2013
Dear MAB, you can solve equation in your desired sequence by using brackets. You can do like this:
Leftside = (-3 + 1) * 10;
Rightside = (8 + 1) / 3;
disp(Leftside)
disp(Rightside)
That's it. Good luck!
  2 Kommentare
MAB
MAB am 13 Okt. 2013
Hey sixwwwwww, I want to write a function that solves the input that a user puts in. So, not knowing how many elements on either side of the inequality could I use your mentioned method of solving a problem like this?
sixwwwwww
sixwwwwww am 13 Okt. 2013
How the user will define the operation on the values which he will input?

Melden Sie sich an, um zu kommentieren.


Walter Roberson
Walter Roberson am 13 Okt. 2013
Do a bunch of string processing.
Remember the position you are in. Scan for the next operator. Convert everything between the remembered position and just before the operator into a number. If you had a pending operation, execute it with the second operator being the number you just read in. Otherwise remember which operator you just got and go back to the beginning of this loop.

Kategorien

Mehr zu Parallel Computing Toolbox finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by