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.

回答 (2 件)

sixwwwwww
sixwwwwww 2013 年 10 月 13 日
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 件のコメント

MAB
MAB 2013 年 10 月 13 日
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 2013 年 10 月 13 日
How the user will define the operation on the values which he will input?

サインインしてコメントする。

Walter Roberson
Walter Roberson 2013 年 10 月 13 日

0 投票

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.

カテゴリ

タグ

質問済み:

MAB
2013 年 10 月 13 日

回答済み:

2013 年 10 月 13 日

Community Treasure Hunt

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

Start Hunting!

Translated by