Hi Guys,
int = zeros(1,length(x)); if k <= 0 int = x ; return end for n = 3:length(x) y1 = x(2:n) ; t1 = ((n-2):-1:0)*dt ; y2 = x(1:n-1) ; t2 = t1 +dt; int(n) = sum (t1.^(k-1)/factorial(k-1).*y1 + t2.^(k-1)/factorial(k-1).*y2)*dt/2 ; end
is there any suggestion to write this part of code more optimal? It is used for computing Integration. The most time consuming line is int(n)= … Whether I can change and remove the for loop here, and implement the for functionality in another way, e.g. vectors? Any suggestions would be appreciated …
Best Answer