How to make a contour plot with data from using ode45
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposta accettata
KSSV
il 1 Ago 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 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Ordinary Differential Equations in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!