필터 지우기
필터 지우기

how to change a matrix variable for each iteration of a matrix loop?

조회 수: 7 (최근 30일)
Sierra Cagle
Sierra Cagle 2015년 3월 31일
답변: Christiaan 2015년 4월 1일
I have an hourly population matrix with defined parameters. One of the variables that defines the parameters is dependent on time. I want to project my matrix forward through 24 hrs. How do I incorporate this time dependent variable?

답변 (1개)

Christiaan
Christiaan 2015년 4월 1일
Dear Sierra,
Assuming that you use a ODE solver like ode 45, and you have a time dependent variable, please have a loop at this MATHWORKS answer.
If you use a for loop for your iterations, and the variable that depends on time, is an input parameter, you can first make a function that specifies the time-dependent parameter at any time. Then you can call the function in the for loop and assign this value in your matrix. A second possibility is to first make an array of that parameter (first row the time, and second row the parameter) and then use an interpolation function (i.e. pchip) to use the correct value of that parameter to update your matrix.
Good Luck! Christiaan

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by