How to plot points from odefun
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Fátima Cecilia Chapa Viejo
el 29 de Nov. de 2020
Comentada: KSSV
el 29 de Nov. de 2020
Hi, so I'm using odefun and ode45 to graph 3 different functions, but additionally I would like to graph specifically some points at several x values (50, 100,150, 200), but since I´m using odefun I don't know how to incorporate it. This is my code:
odefun function:
function yp = odefun(~,y)
yp = zeros(3,1);
yp(1)= (0.48947553*y(1))+(-0.2217926*y(1)*y(2))+(-0.8924614*y(3)*y(1));
yp(2)= (-0.0528409*y(2))+(0.00087705*y(1)*y(2));
yp(3)= (-0.0990983*y(3))+(0.00461634*y(1)*y(3));
ode code:
t0 = 0;
tfinal = 200;
y0 = [60.275818; 2.043051; 0.033794];
[T,Y] = ode45(@odefun,[t0 tfinal],y0);
figure;
plot(T,Y)
0 comentarios
Respuesta aceptada
KSSV
el 29 de Nov. de 2020
Note that Y is a m*3 matrix, you need to plot each column seperately.
figure(1);
plot(T,Y(:,1))
figure(2);
plot(T,Y(:,2))
figure(3);
plot(T,Y(:,3))
2 comentarios
KSSV
el 29 de Nov. de 2020
Use interp1. If x, y are your inputs.
xi = 50 ; % value of x at which you seek output
yi = interp1(x,y,xi) ; % get value yi corresponding to given xi
[xi yi]
Más respuestas (0)
Ver también
Categorías
Más información sobre Discrete Data Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!