Question: Consider the following function. (a) What would be the response to the call fun with no arguments? (b) Rewrite it (the function and default x)
Consider the following function. (a) What would be the response to the call fun with no arguments? (b) Rewrite it (the function and default x) so that it evaluates post fix notation expressions that are formed as nested cell arrays. function [t] = fun(x) if nargin == 0 x = { '+' { '-' { '*' 9 2 } 5} { '/' 18 6 } } }: end if iscell(x) switch x(1) case '+' t = fun (x{2}) + fun (x{3}): case '-' t = fun (x{2}) - fun (x{3}): case '*' t = fun(x{2}) * fun (x{3}): case '/' t = fun (x{2})/fun (x{3}): end else t = x: end
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
