) Sketch the directional field of the equation. (Preferably, using the isoclines you found in (a)).
Use 2, 1,-1,-2,0
Sketching directional field using MATLAB.
To sketch the directional field of the differential equation at the points using MATLAB, you can follow these steps:
Open MATLAB.
Define the differential equation .
Create a grid of points where takes the values .
Calculate the corresponding values using the differential equation.
Use the
quiver
function to plot the directional field using the calculated and values.
Here's the MATLAB code to accomplish this:
% Define the differential equation
dydt = @(y) 1 - y;
% List of y values
yValues = [2, 1, -1, -2, 0];
% Create a grid of points
[y, yprime] = meshgrid(yValues, dydt(yValues));
% Calculate the corresponding y' values
yprime = dydt(y);
% Plot the directional field
quiver(y, yprime, ones(size(y)), yprime, 0.5, 'b');
hold on;
plot(yValues, dydt(yValues), 'ro', 'MarkerSize', 8);
xlabel('y');
ylabel("y'");
title("Directional Field of y' = 1 - y");
grid on;
hold off;
Step by step
Solved in 3 steps with 3 images