Make a slope eld for this equation

8 ビュー (過去 30 日間)
Bob
Bob 2016 年 7 月 28 日
回答済み: Star Strider 2016 年 7 月 28 日
Make a slope field for this equation over the intervals between 0<t<6 and 0<y<1. Equation: 5*y*(1-y)-(1+((sin(2*pi*t))/2))
Attempted code:
syms y(t);
[T, Y] = meshgrid(0:0.2:6, 0:0.2:1);
S = 5*y*(1-y)-(1+(1/2)*sin(2*pi*t));
L = sqrt(1 + S.^2);
quiver(T, Y, 1./L, S./L, 0.45)
axis tight; xlabel('t'), ylabel('y')
title('Slope field field')
Error: Error using quiver (line 44) DOUBLE cannot convert the input expression into a double array.
Error in Project_3 (line 26) quiver(T, Y, 1/L, S/L, 0.45)

採用された回答

Star Strider
Star Strider 2016 年 7 月 28 日
Don’t use the Symbolic Math Toolbox. Use an anonymous function instead:
[T, Y] = meshgrid(0:0.2:6, 0:0.2:1);
S = @(t,y) 5*y.*(1-y)-(1+(1/2)*sin(2*pi*t));
L = sqrt(1 + S(T,Y).^2);
quiver(T, Y, 1./L, S(T,Y)./L, 0.45)
axis tight; xlabel('t'), ylabel('y')
title('Slope field field')
This works. I will leave it to your to determine if it produces the correct results. For information on anonymous functions, see the appropriate sections in Function Basics.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeNumeric Solvers についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by