When using "eval()" with multiple commands inside, assigning the output to a variable causes an error – which varies depending on MATLAB version.
>> c = eval('a=2;b=3;a+b')
In MATLAB R2018a and later:
Error: Incorrect use of '=' operator. To assign a value to a variable, use '='. To compare values for equality, use '=='.
In MATLAB R2017b and earlier:
Error: The expression to the left of the equals sign is not a valid target for an assignment.
Is it possible to capture the numerical output? Namely assign "a+b" to the variable "c" in this example
Best Answer