From: Robert Zack on
I've been looking for a way to read invariables from a function using varargin in such a way that I can reference the same variables in the called function to evaluate a function.


for example

%Base program
func = 'var1*var2*sin(x)'
back = fun(func,var1,var2)


%Function called
function [back] = fun(func,varargin)
%now that i read everything in the program i want to evaluate the function

for i = 1:somenumber
x = i;
back = eval(func);
end

i kept trying to use assignin, but to no avail... is there something else i could use to accomplish this?