How to describe value changes in constant intervals?
Show older comments
Hi everyone, I have problem with describe value change in time in constant intervals in ode45 function. When I describe
A=200*(t>=0 & t<5)+300*(t>=5 & t<10)+550*(t>=10 & t<15)...etc.
then ode 45 understand this value change in time, but I have much more intervals from excel data and I want automatization this process of describing.
Let's say I have what the following:
tspan=(0:60:1800);
It=[1000;600;1200]; % after processing Excel data
l=0;
for k=1:3
while (l<600*k & l>=600*k-600)
A=It(k);
l=l+60;
end
end
However in this case, the ode function accepts only the last 1200 and calculates the result, for 1200 for the whole time.
Have anybody any ideas how to solve this problem?
2 Comments
Jan
on 24 Oct 2018
I do not understand, what you want to achieve.
By the way, do you run ODE45 on a function, which is not smoothly differentiable? This would be a bad idea, see http://www.mathworks.com/matlabcentral/answers/59582#answer_72047 .
Henry Gaston
on 25 Oct 2018
Accepted Answer
More Answers (0)
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
