-2

y=3-2y is my equation.

I have been studying matlab and I cannot understand how to make a quiver plot for this differential equation. I wanted to know how it behaves as it reaches infinity, graphically using matlab.

grizzthedj
  • 7,131
  • 16
  • 42
  • 62

2 Answers2

2

You should use the quiver function as follows:

f = @(t,y)3-2*y;
t = -2:0.2:2;
y = -2:0.2:2;

[T,Y] = meshgrid(t,y);

dt = t(2) - t(1);
dt2 = dt / 2;
dy = y(2) - y(1);
dy2 = dy / 2;

tmin = t(1) - dt2;
tmax = t(end) + dt2;
ymin = y(1) - dy2;
ymax = y(end) + dy2;

fv = eval(vectorize(f));
yp = feval(fv,T,Y);

u = 1./max(1/dt,abs(yp)./dy)*0.35;
v = u .* yp;

quiver(t,y,u,v,0,'.r');
hold on;
quiver(t,y,-u,-v,0,'.r');
hold off;

axis([tmin tmax ymin ymax]);

Output:

Output

The plot should provide you a clear insight concerning the behavior of y and this should help you out determining how the solution behaves when proceeding towards infinity.

Tommaso Belluzzo
  • 23,232
  • 8
  • 74
  • 98
0
  1. There is a quiver function! Quiver

  2. If t is time, nothing happens to it as it approaches infinity. It just approaches infinity. I think you mean y. This differential equation can't actually be represented by a quiver plot, as you'll note by the documentation. There is no x or x' ("u") component. I think in this case it would help for you to solve the differential equation for y

Edit Seems my math is wrong per other answer! If you had solved for y you would have found that y = Ce^(-2t) + 1.5. Thanks Tommaso

squeegene
  • 467
  • 1
  • 5
  • 18