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

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.

Answers (2)

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 Comments

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?
How the user will define the operation on the values which he will input?

Sign in to comment.

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.

Categories

Find more on Parallel Computing Toolbox in Help Center and File Exchange

Tags

Asked:

MAB
on 13 Oct 2013

Answered:

on 13 Oct 2013

Community Treasure Hunt

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

Start Hunting!