A way to get MatLab to solve inequality from left to right and not by order of operation?
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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.
0 Kommentare
Antworten (2)
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
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.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Parallel Computing 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!