The following code is taking a most of the time in my script and I have to run the script many times Is there a way to reduce the time for its execution.
t=0:200000;lambda=[1,2,3;4,5,6;7,8,9;10,11,12];for trans=1:size(lambda,1) uh_fun{trans}=expconv(lambda(trans,:));enduh=zeros(length(t),1);for i=1:length(uh_fun) temp_uh_fun=uh_fun{i}; f_gamma=zeros(length(t),1); for j=1:length(temp_uh_fun) f_gamma=f_gamma+temp_uh_fun{j}(t)'; % this line take a lot of time
end uh=uh+p(i)*f_gamma; % p is an array of scalars
end
I have added expconv function for reference. I need some suggestions to improve the performance. I have also attached a pdf which contains profiler analysis of anonymous function in expconv.
Best Answer