How can i make the integral curves?

조회 수: 15 (최근 30일)
Yoanna Vasileva
Yoanna Vasileva 2021년 1월 14일
댓글: Alan Stevens 2021년 1월 16일
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"

채택된 답변

Alan Stevens
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
Yoanna Vasileva
Yoanna Vasileva 2021년 1월 15일
Thank you for your response. But is giving me this errors now:
Error using symengine (line 59)
DOUBLE cannot convert the input expression into a double array.
If the input expression contains a symbolic variable, use VPA.
Error in sym/double (line 583)
Xstr = mupadmex('symobj::double', S.s, 0);
Error in new (line 14)
yy = double(subs(sol1,'t',xx));
I am not sure if my sol is okay I mean if the given equation is equivalent to the sol solution. Also I am using 2015 MatLab and this may the problem. How would you solve it. I don`t know if my way of solving is right.
Alan Stevens
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개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

제품


릴리스

R2015a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by