Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %steven pitman
- %clear screen and memory
- clear, clc
- %define the function
- yprime = @(x,y) -(3*x.^2).*y;
- %define solution curves
- f1 =@(x) 2*exp(-x.^3);
- f2 =@(x) 1*exp(-x.^3);
- f3 =@(x) 1*exp(-x.^3);
- f4 =@(x) 3*exp(-x.^3);
- f5 =@(x) 4*exp(-x.^3);
- %define points to determine slope
- xx = [0:.2:3]';
- yy = [0:.2:3];
- %x and y components of the slope vectors
- dy = yprime(xx,yy);
- dx = ones(size(dy));
- %vector to normalize slope
- L=sqrt(1+dy.^2);
- %plot the slope field and solution curves
- figure();
- hold on
- quiver(xx,yy,dx./L,dy./L)
- xlim([0,3])
- ylim([0,3])
- fplot(f1,[0,3],'LineWidth',2);
- fplot(f2,[0,3],'LineWidth',2);
- fplot(f3,[0,3],'LineWidth',2);
- fplot(f4,[0,3],'LineWidth',2);
- fplot(f5,[0,3],'r','LineWidth',2);
- hold off
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement