Hello all. I am attempting to translate a MATLAB file that evaluates a 
string column by column. The function is simple, pasted below:

function y = mapcol(text,p0,p1,p2)
%MAPCOL                                                 
%     mapcol(STRING,A,B,C)  will execute the command
%       contained in STRING over the columns of the matrix A,
%       creating one column of the output matrix at a time.
%       The additional arguments B and C are available to pass parameters.
%     EX:  mapcol('x.*p1',A,b) will do a point-wise
%          multiplication of each column of A by the vector b.
%
[M,N] = size(p0);
y = [];
for i=1:N
   x = p0(:,i);
   y(:,i) = eval(text);
end

In trying to write the equivalent function in Julia, I ran into issues 
regarding eval() only having access to variables at the global level. Is 
this possible to translate?/ How would I go about doing so (preferably 
without too much added complexity, which I noticed in other threads 
regarding the scope of eval)? I realize that this function may not appear 
to be very useful on the surface, but for me it would be worth having as a 
tool to use in other functions.

Any feedback is appreciated. Thanks.

Reply via email to