Help With ODEs Solver(ode45)
Afficher commentaires plus anciens
function [] = call_func
clear all
close all
tspan = [ 0 10 ]
y0 = 0:0.01:1;
x0 = 0:0.01:1;
theta0 = 0:pi/5:2*pi;
l = 1;
options=odeset('RelTol',1e-8,'AbsTol',1e-8)
for k = 1:length(y0)
for s = 1:length(x0)
for w = 1:length(theta0)
[t,x] = ode45(@func,tspan,[x0(s) y0(k) theta0(w)],options);
%legend('b = blue', 'r = red')
if (max(mod(x(:,1),l))<0.5) && (min(mod(x(:,2),l))>0.5)
c='r.';
else
c='b.';
end
plot(mod(x(end,1),l),mod(x(end,2),l),c);
hold on
end
end
end
end
function dydt = func(t,x)
Vs = 0.095;% true value
alpha =1; % true value
dydt = [sin(2*pi*x(1))*cos(2*pi*x(2))+Vs*cos(x(3))
-cos(2*pi*x(1))*sin(2*pi*x(2))+Vs*sin(x(3))
2*pi*(-alpha*cos(2*pi*x(1))*cos(2*pi*x(2))*sin(x(3))+sin(2*pi*x(1))*sin(2*pi*x(2)))];
end
I use this code to analyze a fluid system. The problem is it take sometimes up to 20 mintues to get results. Does anyone know if there is a way to solve and get the plot a quicker way?
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Programming 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!