how to solve ode if value of constant is vector
조회 수: 5 (최근 30일)
이전 댓글 표시
function [dydt] = diffvar(t,y)
dydt=-k*y+a;
end
end
in this if a is vector how to solve
댓글 수: 0
답변 (1개)
Ameer Hamza
2020년 10월 21일
편집: Ameer Hamza
2020년 10월 21일
If k and a are constant vectors of equal length the following will work
k = rand(10, 1);
a = rand(10, 1);
IC = zeros(10, 1);
tspan = [0 10];
[t, y] = ode45(@(t,y) diffvar(t,y,k,a), tspan, IC)
plot(t, y)
function [dydt] = diffvar(t,y,k,a)
dydt=-k.*y+a;
end
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!