2 views (last 30 days)

such a given operation (1/2+1/3)/456*789

Stephen Cobeldick
on 25 Sep 2018

I suspect that you might mean this:

Bruno Luong
on 26 Sep 2018

Stephen Cobeldick
on 30 Sep 2018

"if i want to use the the debugging tools.for this operation how can i do this"

I don't know if it is possible to do exactly what you want. I wrote that the closest solution might be to use the debugging tools (in particular the step in command). But how useful that would be depends on what commands in your code are functions and which ones are compiled/inbuilt. But there is nothing stopping you from giving it a try:

Bruno Luong
on 26 Sep 2018

Edited: Bruno Luong
on 26 Sep 2018

Here is an idea, replace the number of your expression by functions (that return a scalar) and print out the order

% (1/2+0/3)/456*789

(f(1)/f(2)+f(0)/f(3))/f(456)*f(789)

function x = f(x)

disp(x)

end

When run it you'll get

>> printorder

1

2

0

3

456

789

ans =

0.8651

Insert the operator(s) (there is only one right way to do it) you'll get the polish-reverse notation of the expression

1; 2; /; 0; 3; /; +; 456; /; 789; *

Meaning the expected specified evaluation order we told you.

Walter Roberson
on 26 Sep 2018

MATLAB parses into a threaded code structure, not a postfix stack, so it does not use a swap operation.

It perhaps uses a tree and if so then it probably follows the left edge for execution order.

James Tursa
on 30 Sep 2018

Bruno Luong
on 30 Sep 2018

Bruno Luong
on 26 Sep 2018

Edited: Bruno Luong
on 26 Sep 2018

f(3)^f(4) would have to be done first

That's the case, the power is the first to be performed (among operators), but it's not saying the operands f(3) and f(4) are evaluated first.

Opportunities for recent engineering grads.

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

Start Hunting!
## 1 Comment

## Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/420691-can-anyone-suggest-me-a-command-that-talks-about-how-matlab-performed-an-arithmetic-operation-its-s#comment_616113

⋮## Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/420691-can-anyone-suggest-me-a-command-that-talks-about-how-matlab-performed-an-arithmetic-operation-its-s#comment_616113

Sign in to comment.