Can ode45 be used to solve mx'' + cx' + kx^1.1=0 x(0)=5;x'(0)=0? Getting complex numbers in answers.

조회 수: 3 (최근 30일)
I want to examine the transient response of a second order system with a nonlinear spring force. For example Fspring=kx^n where 0<n<2. I get answers when using ode45, but also a warning, when n is not =1, when plotting that tells that the numbers are complex but only the real part is plotted. Can ode45 be used for this problem? If not, can you suggest alternate. Thanks....version 9.7.0.1296695 (R2019b) Update 4
  댓글 수: 1
Richard Klein
Richard Klein 2020년 7월 2일
Thanks for your quick response. The complex answers were bothersome to me, and I have since seen an error in my problem formulation. Your answer helped push my thinking in the right direction. Thanks again.

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

채택된 답변

Star Strider
Star Strider 2020년 6월 29일
You need to plot the real and complex parts separately.
Assuming:
[t,y] = ode45(yourOdefcn, tspan, ic);
plot it as:
figure
plot(t, real(y))
hold on
plot(t, imag(y))
plot(t, abs(y))
hold off
grid
depending on the result you want.
.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by