direction field and solution curve for differential equation.

조회 수: 21 (최근 30일)
Hyun Suk Song
Hyun Suk Song 2020년 9월 15일
답변: esat gulhan 2020년 9월 16일
given function dy/dt = -ty^3
the solution of function is +-1/sqrt(t^2+C) and y(0) = +-1/sqrt(c).
I cannot deal with this solution with C
How can I find solution curves for the differential equation and combined graph of solution curve with direction field.
For solution curve, I used
syms y(t) c
sol = dsolve(diff(y, t) == -t*y^3, y(0) == [-1 1]/sqrt(c))
fplot (sol, [-3, 3])
For direction field
[T, Y] = meshgrid(-2:0.2:3, -1:0.2:2);
S = -t*y^3;
L = sqrt(1 + S.^2) <- I don't know what that means actually
quiver(T, Y, 1./L, S./L, 0.5) axis equal tight
Please help me!

답변 (2개)

esat gulhan
esat gulhan 2020년 9월 15일
Maybe like this
if it works please accept the answer
clc; clear;
syms y(t) c
sol = diff(y, t) == -t*y^3 %your equation
cond=y(0) == 1/sqrt(c); %condition for 1/sqrt(c)
sol2=(dsolve(sol,cond));%solution of differential in cond
cond2=y(0) == -1/sqrt(c);%condition for -1/sqrt(c)
sol3=(dsolve(sol,cond2));%solution of differential in cond2
for c=linspace(0.25,10,8); %c values for condition, i take it free, you can change it
t=linspace(-3,3,100);%t values in -3 3 with 100 divides
plot(t,subs(sol2),'b','LineWidth',1.5); %plot lines with cond 1
hold on
plot(t,subs(sol3),'b','LineWidth',1.5);grid on;%plot lines with cond 2
end
[t, y] = meshgrid(-3:0.2:3, -2:0.2:2);%limits of meshgrid
S = -t.*y.^3;
L = sqrt(1 + S.^2)
quiver(t, y, 1./L, S./L, 0.5)
set(gca, 'XLim', [-3 3], 'YLim', [-2 2]);%limits of graph
  댓글 수: 1
Hyun Suk Song
Hyun Suk Song 2020년 9월 16일
Actually they give me this
Error using plot
Data must be numeric, datetime, duration or an array convertible to double.
Error in projectB (line 34)
plot(t, subs(sol2), 'b', 'LineWidth',1.5);
I don't know why this code is not working

댓글을 달려면 로그인하십시오.


esat gulhan
esat gulhan 2020년 9월 16일
Did you copy to code in a new blank script. It is not an extension of a code it is a new indepentend code. It must work. Impossıble not to work. plot(t, subs(sol2), 'b', 'LineWidth',1.5); can not be in line 34 in ,it is in line 12.
Plot will seen like this

카테고리

Help CenterFile Exchange에서 Linear Algebra에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by