In the Matlab Anonymous Functions, I want to have Functions fun_total like this
fun_total = @(x) [ 0;
1*x(1);
1*x(1);
2*x(2);
2*x(2);
...
100000*x(100000);
100000*x(100000);]
so here is my code
fun_total = @(x) [0];
for i = 1 : 100000
fun_temp = @(x) i*x(i);
fun_total = @(x) [ fun_total(x); fun_temp(x) ];
fun_total = @(x) [ fun_total(x); fun_temp(x) ];
end
My problem is it's too slow when loop iteration become bigger.
Every time fun_total = @(x) [ fun_total(x); fun_temp(x) ];
The fun_total(x) will expand first ,and then merge.
Now I have a solution is output my fun_total as a text file, and then change to function. Is this can work? or someone have other efficient solution? Thanks!!