How to run function within for loop
Mostrar comentarios más antiguos
The code given below solves the delayed type differential equation. I want to run this code for >10,000 different combinations of
and
. That is,
and
;
function [sol]=system_simulation
po=1.4; do=8; tau=0.5; xth=0.2; vth=0.2;ksi=0.25;
option=odeset('RelTol', 1e-4, 'AbsTol', 1e-4);
sol = dde23(@syst,[tau],@hystory,[0 100],option);
figure(1), plot(sol.x,sol.y(1,:));
% --------------------------------------------------------------------------
function s = hystory(t)
% Constant history function for inverted pendulum.
s = [0.4;0.1];
end
% --------------------------------------------------------------------------
function xprime = syst(t,x,Z)
xlag=Z(:,1);
xprime=zeros(2,1);
xprime(1)=x(2);
xprime(2)=x(1)-p*xlag(1)-d*xlag(2);
end
end
2 comentarios
Geoff Hayes
el 21 de Mzo. de 2019
Mirlan - you want to iterate over po and do but nowhere do you reference them. How should they be used? (It is also doubtful you want to plot the results for all 10000 iterations so please discuss what you want to save/store from each iteration.
Mirlan Karimov
el 22 de Mzo. de 2019
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Delay Differential Equations en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!