How to create a loop on function handle
Afficher commentaires plus anciens
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)))];
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Startup and Shutdown dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!