How can i make the integral curves?
10 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Yoanna Vasileva
am 14 Jan. 2021
Kommentiert: Alan Stevens
am 16 Jan. 2021
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 Kommentare
Akzeptierte Antwort
Alan Stevens
am 15 Jan. 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 Kommentare
Alan Stevens
am 16 Jan. 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)
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!