How to make a contour plot with data from using ode45
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
So for my code im trying to vary two parameters used in a system of differential equations and evaluate how those different values affect a subset of the solution. I want to do this by creating a contour plot, but I cant seem to get my data to ailgn correctly.
X= linspace(1,5,5); % Vector for alpha_p values
Y= linspace(0.5,3,5); % Vector for beta_p values
[A, B]= meshgrid(X,Y);
for i= 1:length(A)
for j=length(B)
[t,x] = ode45(@(t,x) pulsegenerator_function2(t, x, 1, 5, 0.75, A(i,j), B(i,j), 5,...
0.75, A(i,j), B(i,j), 1, 2, 0.75, A(i,j), B(i,j), 3, 1, 2, 1 ), linspace(0,10,75), [0.1 0 0 0 0 0]);
so this is what I have right now, essentially I have a bunch of paramenters (as you can see after t and x in the function) and I'm trying to vary 2 of them at all possible combnations with each other and i dont know how to successfully do that.
After this issue I still dont understand how I can get the right size data to work for making a contour plot, but it might have to do with this first part so thats the most pressing issue at the moment
2 Kommentare
Akzeptierte Antwort
KSSV
am 1 Aug. 2020
X= linspace(1,5,5); % Vector for alpha_p values
Y= linspace(0.5,3,5); % Vector for beta_p values
[A, B]= meshgrid(X,Y);
nt = length(x) ; [m,n] = size(A) ;
Z = zeros(m,n,nt) ;
for i= 1:length(A)
for j=length(B)
[t,x] = ode45(@(t,x) pulsegenerator_function2(t, x, 1, 5, 0.75, A(i,j), B(i,j), 5,...
0.75, A(i,j), B(i,j), 1, 2, 0.75, A(i,j), B(i,j), 3, 1, 2, 1 ), linspace(0,10,75), [0.1 0 0 0 0 0]);
Z(i,j,:) = x ;
end
end
for i = 1:nt
contour(A,B,Z(:,:,i)
title(sprintf("contour at time step = %d",i))
drawnow
pause(1)
end
2 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Ordinary Differential Equations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!