Hi, I am a little stuck trying to create an ODE function which has a time dependent variable. At first I had the following which worked well:
K = ...;
r = ...;
C = ...;
m = ...;
myODE = @(t,z) [z(2);(F - K*r*z(1) - C*r*z(2))/m];
However now, I'd like F to change as a function of time. I looked into using 'interp1' from the example on the Mathworks site but I'm still confused as to how to use it. I essentially want to change F from a step to a sine or ramp wave. Have F start at 0 and over 2 seconds ramp it up to another value.
I'm not looking for a complete solution, but I'd like to know how I can successfully use the interp1 function.

 채택된 답변

Steven Lord
Steven Lord 2016년 9월 8일

0 개 추천

Take a look at this answer (which for me was listed as "Related Content" on the right side of this page) for an example of how to use interp1 inside a call to the ODE solver.

추가 답변 (0개)

카테고리

질문:

2016년 9월 8일

답변:

2016년 9월 8일

Community Treasure Hunt

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

Start Hunting!

Translated by