Write Function Evaluate Binary Expression Character Array Without Directly Converting Nume Q37060793

Write a function to evaluate a binary expression character arraywithout directly converting to numeric value. (Matlab)


Solution


Program:

EvalBinExp.m function res=EvalBinExp (binexp) [m, n]=size (binexp); numl=0; num2=0; $ process the character array, character

$ apply the corresponding binary bperation on $ the two numeric values if binexp (i)==+ res=numl+num2; elseif binexp (i)==

Sample output:

Command Window >> bexp=205+3487; >> res=EvalBinExp (bexp) res = 3692 fx >>

Code to copy:

% EvalBinExp.m
function res=EvalBinExp(binexp)
    [m,n]=size(binexp);
    num1=0;
    num2=0;
    % process the character array, character bycharacter
    for i=1:n
        % continue, until thecharacter is not a binary operator
        if binexp(i)>=48&&

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.