I was encountered with usage of function eval(expression) in somebody else's code in matlab: for example:
for n = 1 : 4
sn = int2str( n) ;
eval( [ 'saveas( fig' sn ', [ sName' sn ' ], ''fig'' ) ' ] );
end
MathWorks stuff in Matlab Help pointed out that:
Many common uses of the eval function are less efficient and are more difficult to read and debug than other MATLAB functions and language constructs.
After this, I find usage of this function in many other program languages, so as Python, JavaScript, PHP.
So I have a few questions:
- Will usage of this function be enfluenced on the performance of my code?
- If it will slow down execution, why does it occur?
- If it slow down execution every time when called, what reason for use this function in principle?