how to solve ode if value of constant is vector

5 visualizaciones (últimos 30 días)
prajyot gajbhiye
prajyot gajbhiye el 21 de Oct. de 2020
Editada: Ameer Hamza el 21 de Oct. de 2020
function [dydt] = diffvar(t,y)
dydt=-k*y+a;
end
end
in this if a is vector how to solve

Respuestas (1)

Ameer Hamza
Ameer Hamza el 21 de Oct. de 2020
Editada: Ameer Hamza el 21 de Oct. de 2020
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

Categorías

Más información sobre Programming en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by