How can i make the integral curves?
조회 수: 15 (최근 30일)
이전 댓글 표시
My task is to find the general equation of 2x^2y′ − xy − y3 = 0
and draw in the square {x ∈ [1,6], y ∈ [-3,2]} a vector field
tangent to the integral curves of the equation.
and Draw the integral curves of the equation.
[x,y] = meshgrid(1:0.5:6,-3:0.5:2);
u = ones(size(x));
v = (x.*y+y.^3)/2*x.^2;
r = sqrt(u.^2 + v.^2);
plot([0,0],[-3,2])
hold on
plot([1,6],[0,0])
quiver(x,y,u./r,v./r,'k');
axis ([1 6 -3 2]);
sol = dsolve('2*t^2*Dy=t*y+y^3');
for k = 2.1:0.4:2.6
sol1 = subs(sol,'C7', k^3);
xx = 1:.1:6;
yy = subs(sol1,'t',xx);
hold on
plot(xx,yy,'r');
hold off;
end
This is my code the error which is giving me is "Error using plot
A numeric or double convertible argument is expected"
댓글 수: 0
채택된 답변
Alan Stevens
2021년 1월 15일
Like so?
[x,y] = meshgrid(1:0.5:6,-3:0.5:2);
u = ones(size(x));
v = (x.*y+y.^3)/2*x.^2;
r = sqrt(u.^2 + v.^2);
plot([0,0],[-3,2])
hold on
plot([1,6],[0,0])
quiver(x,y,u./r,v./r,'k');
axis ([1 6 -3 2]);
sol = dsolve('2*t^2*Dy=t*y+y^3');
xx = 1:.1:6;
for k = 2.1:0.4:2.6
sol1 = subs(sol,'C1', k^3); %%% C1 not C7
yy = double(subs(sol1,'t',xx));
end
plot(xx,yy,'r');
댓글 수: 2
Alan Stevens
2021년 1월 16일
It works ok for me, producing the following graph
Did you copy and paste into a fresh script? In particular did you notice that in the line before your error line you need to replace C7 by C1.
(I used R2018b to do this. I don't know if this is significantly different from R2015 here)
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!