I need to determine the flight time and name it P2A and I am having a hard time because it is returning as 0

1 回表示 (過去 30 日間)
I am using Matlab and this is my code so far.
a=4
b=2
c=7
d=13
syms t
abs(t)
vo=45+a;
do=.044+(b/50)
yo=1
g=9.81
x=(vo*cos(do))*t
y=-(g/2)*t^2+(vo*sin(do))*t+yo
I need to ensure that "t" only takes on postive values and I need to determine the flight time of the baseball using solve and double. Finally I need to call this result P2A
Can you pls help?

採用された回答

Devesh Bhasin
Devesh Bhasin 2022 年 11 月 10 日
Hi Jaden,
For using the 'solve' function, I recommend going through the the examples in the function's documentation. The following is one relevant example that shows the use of 'solve' function to get real solutions:
For the condition that 't' needs to be positive, the following are the alternatives:
1. You can include the equation 't>0' in your system of equations as an input to the 'solve' function.
2. You can call the assume function before solving the equations as:
assume(t>0)
For more information, please refer to the following documentation for the 'assume' function:
3. You can solve for 't^2' instead of 't' and then square the resulting solution at the end. This method is explained in the following MATLAB Answers post:
https://www.mathworks.com/matlabcentral/answers/164468-how-to-make-sure-that-fsolve-gives-only-positive-values-as-the-solution

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by