How can i make the integral curves?

19 visualizzazioni (ultimi 30 giorni)
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"

Risposta accettata

Alan Stevens
Alan Stevens il 15 Gen 2021
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 Commenti
Yoanna Vasileva
Yoanna Vasileva il 15 Gen 2021
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 il 16 Gen 2021
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)

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange

Prodotti


Release

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by