From: Jose on
Hello guys, i have this piece of code:

depth=[1 2 3 4]
panelx=[2 3 5 6]
k=length(panelx)

load data.mat


for I=1:k
e=panelx(I)
epsn(e)=depth(I)
xdata=datax(:,I);
sendvar2m(e)=proc1serial(e,xdata,epsn)
end


I would like to subs proc1serial for the the fuction procIserial, where the variable I can change with the loop.

Any help?

Thanks.
From: Sean on
"Jose " <jose.l.vega(a)gmail.com> wrote in message <i24jf8$adm$1(a)fred.mathworks.com>...
> Hello guys, i have this piece of code:
>
> depth=[1 2 3 4]
> panelx=[2 3 5 6]
> k=length(panelx)
>
> load data.mat
>
>
> for I=1:k
> e=panelx(I)
> epsn(e)=depth(I)
> xdata=datax(:,I);
> sendvar2m(e)=proc1serial(e,xdata,epsn)
> end
>
>
> I would like to subs proc1serial for the the fuction procIserial, where the variable I can change with the loop.
>
> Any help?
>
> Thanks.

Use anonymous functions:
my_fun =@(e,xtata,epsn)proc1serial(e,xdata,epsn)
then when you need to change it redefine myfun:
my_fun =@(e,xtata,epsn)procIserial(e,xdata,epsn)

sendvar2m(e)= my_fun(e,xdata,epsn);
From: someone on
"Jose " <jose.l.vega(a)gmail.com> wrote in message <i24jf8$adm$1(a)fred.mathworks.com>...
> Hello guys, i have this piece of code:
>
> depth=[1 2 3 4]
> panelx=[2 3 5 6]
> k=length(panelx)
>
> load data.mat
>
>
> for I=1:k
> e=panelx(I)
> epsn(e)=depth(I)
> xdata=datax(:,I);
> sendvar2m(e)=proc1serial(e,xdata,epsn)
> end
>
>
> I would like to subs proc1serial for the the fuction procIserial, where the variable I can change with the loop.
>
> Any help?
>
> Thanks.

See the answer to Q4.6 of the MATLAB FAQ at:

http://matlabwiki.mathworks.com/MATLAB_FAQ

You should be able to adapt the solution to meet your needs.
From: Steven_Lord on


"Jose " <jose.l.vega(a)gmail.com> wrote in message
news:i24jf8$adm$1(a)fred.mathworks.com...
> Hello guys, i have this piece of code:
>
> depth=[1 2 3 4]
> panelx=[2 3 5 6]
> k=length(panelx)
>
> load data.mat
>
>
> for I=1:k
> e=panelx(I)
> epsn(e)=depth(I)
> xdata=datax(:,I); sendvar2m(e)=proc1serial(e,xdata,epsn)
> end
>
>
> I would like to subs proc1serial for the the fuction procIserial, where
> the variable I can change with the loop.
>
> Any help?

Construct the string containing the name of the function and convert it into
a function handle using STR2FUNC, then invoke the function using the
function handle.

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com