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

3 次查看(过去 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 CenterFile Exchange 中查找有关 Mathematics 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by