For the following test function, I would like to sum up function handles which are allocated in a cell. This summation must be a function handle of it own, such that i can insert a vectorial input. For this purpose, I tried the following:

`clear; close all; clcx=0:0.01:pi; %Input vector`

n=5; %order

m=0:n; %Positive modes

%My example function

y=cell(length(m),1);for k=1:length(m)y{k}=@(arg) sin(m(k)*arg);endy=reshape(y,[1,length(m)]);figure(1)hold onfor k=1:length(m)plot(x,y{k}(x));endhold offxlim([x(1) x(end)])grid on%Summation of function handles y

%Here the error starts to occur

ysum=@(x) sum(cellfun(@(F) F(arg),y));figure(2)plot(x,ysum(x))xlim([x(1) x(end)])grid on

I hope somebody is able to help me out with this one. Eventually i have to apply something similar to another code but with more complexity. Thanks in advance!

## Best Answer