How to create a loop on function handle
이전 댓글 표시
I want to write the following in an efficent way using a loop over j = 1:n. A is n by n matrix, t(i) is a scalar (where i is another index, c is n by 1 vector, and f is a function handle. I want the output to be function handle XI which is an n by 1 vector and whose argument is the vector xi of length n by 1
Here n = 3, but I want it for general n.
A = ones(3,3);
c = ones(3,1);
f = @(t,y) t * y;
XI = @(xi) [xi - (y(i,:) + dt* A(:,1) .* f(t(i)+c(1)*dt,xi(1)) +...
dt* A(:,2) .* f(t(i)+c(2)*dt,xi(2)) +...
dt* A(:,3) .* f(t(i)+c(3)*dt,xi(3)))];
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!