how to solve ode if value of constant is vector
2 ビュー (過去 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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Ordinary Differential Equations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!