How can i make the integral curves?
12 ビュー (過去 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!