Solving the differential equation gives unexpected results. How to fix that?

When I solve the differential equation using Matlab, the result is as shown. It's correct, but entering input parameters such as m0 (initial mass), m0 > 0 but the resulting equation has log(- m0) leads to wrong results. Does anyone know how to fix this? Thank you very much everyone.

댓글 수: 1

Hi Ly,
For future reference, please don't post screenshots of code. Instead, just copy/paste your code into the question, which makes it easier for someone else to then copy/paste your code to run it, debug it, etc. When inserting code, please use code formatting by clicking the left-most icon on the Code section of the ribbon.
What's supposed to happen in this system when t is large and m0 - k*t < 0? (asuming k > 0)
Is the sign on the k*v0 term correct (assuming k > 0)?
Is the equation for ysol correct? As written, the second term on the right is integrating backwards in time. Is that the intent?

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

답변 (1개)

Torsten
Torsten 2024년 11월 17일
이동: Torsten 2024년 11월 17일
Better ?
v(t) = v(0) - g*t - v0*log(m0/(m0-k*t))

댓글 수: 3

Thank you. But is there any way to display the output using such an expression?
I think you have to do it "by hand".

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

카테고리

도움말 센터File Exchange에서 Programming에 대해 자세히 알아보기

제품

릴리스

R2024b

태그

질문:

2024년 11월 17일

댓글:

2024년 11월 17일

Community Treasure Hunt

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

Start Hunting!

Translated by