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 CenterFile Exchange에서 Mathematics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by