How to make a contour plot with data from using ode45
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
KSSV
2020-8-1
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Ordinary Differential Equations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!