Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

MATLAB OUESTION HELP PLEASE!!! In Matlab, one can plot direction fields for firs

ID: 3012166 • Letter: M

Question

MATLAB OUESTION HELP PLEASE!!!

In Matlab, one can plot direction fields for first order differential equations that are in normal form. Provide the required commands in your answers to the questions below;

a) First you will need to create evenly spaced grid of points using the function meshgrid. In the command window, type [X Y]=meshgrid(0:1:5,0:1:5) Explain what each of these six inputs of “meshgrid” are for.

b)Now create a grid of points for the rectangle {(X,Y): 0 x 10, 0 Y 10 } where the spacing for X and Y coordinates are 0.2 unit.

c)One can create a matrix of slopes for a given function f(X,Y) by typing “dY=f(X,Y)”. Create a matrix of slopes for the function in the right hand side of the normal form of the following differential equation; y'+y =sin(2x)

d)Notice that 'dy' is actually a matrix. Create a matrix with name “dx” which has the same dimension as dy and has value 1 in each coordinate by using “size()” command.

e)In the command window, type “help quiver” and learn about the quiver function, which can be used to plot vectors at each point of a grid. Now you are going to plot the direction field for the differential equation given in the part c). Before doing so, we need to scale all the vectors to have unit length. So to create a matrix consisting of the lengths of the vectors, type the following in the command window; L=sqrt(1+dY.^2); Use this to normalize the vector (dX,dY), then plot the direction field by use of quiver function and provide the resulting graph.

f)Lastly, type “axis tight”, provide the resulting graph, what is the function of this command? Provide the resulting graph.

Explanation / Answer

[X Y]=meshgrid(0:1:5,0:1:5) this will create a mess of numbers and assign to X and Y.

X =

0 1 2 3 4 5
0 1 2 3 4 5
0 1 2 3 4 5
0 1 2 3 4 5
0 1 2 3 4 5
0 1 2 3 4 5


Y =

0 0 0 0 0 0
1 1 1 1 1 1
2 2 2 2 2 2
3 3 3 3 3 3
4 4 4 4 4 4
5 5 5 5 5 5
Above will be the result of the command given. 0;1;5 in meshgrid is 0 is the starting point 1 is the intervals integers are spaced and 5 is the last limit till integers are increased.
b.) [X Y]=meshgrid(0:0.2:10,0:0.2:10) this will create that.