how to draw a slope field in matlab

蹲街弑〆低调 提交于 2019-12-05 17:17:01

so here is the equation:

dx/dt = x^2-3xy+y
dy/dt = -5x+sin(yx)

That is the code, which will help to do the job:

[x,y] = meshgrid(-2:0.2:2);
dx = x.^2-3*x.*y+y;
dy = -5*x+sin(x.*y);
r = ( dx.^2 + dy.^2 ).^0.5;
px = dx./r;
py = dy./r;
quiver(x,y,px,py);

It is also possible to use the package dfield. You can read it here. But I have not tested it for myself

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!