How to solve a differential equation with non-constant coefficients
Mostrar comentarios más antiguos
Hi all
I have equation like this dy/dx = a(x)*y + b
where : a(x) is non constant (a=1/x) and b is a vector (10000 rows)
how can I solve this equation using matlab !!
Someone answer me plz
Respuestas (3)
Torsten
el 8 de Jun. de 2017
0 votos
Take a look at the example
ODE with Time-Dependent Terms
under
https://de.mathworks.com/help/matlab/ref/ode45.html
Best wishes
Torsten.
4 comentarios
arbia haded
el 9 de Jun. de 2017
arbia haded
el 12 de Jun. de 2017
Torsten
el 13 de Jun. de 2017
So you want to solve the ODE
y'=y/x-sqrt(Bx^2+By^2+Bz^2)
for all combinations (Bx,By,Bz) from your loaded arrays ?
Then use a loop over the length of Bx:
a = @(x) 1/x;
xdomain = linspace(1,100,10);
y0=1;
%b = rand(10000,1);% aléatoire
load ('Bx');
load ('By');
load ('Bz');
for i=1:numel(Bx)
f=@(x,y) a(x)*y-sqrt(Bx(i)^2+By(i)^2+Bz(i)^2);
[x,y]=ode45(f,xdomain,y0);
yvec(i,:)=y(:);
end
Best wishes
Torsten.
arbia haded
el 13 de Jun. de 2017
Francisco Rosales
el 15 de Mayo de 2020
0 votos
Hi all
I have equation like this Az'(t) = Bz(t)+ b
how can I solve this equation using matlab !!
Someone answer me plz
Thaks
Grace
1 comentario
darova
el 16 de Mayo de 2020
Create your own question
Categorías
Más información sobre Solver Outputs and Iterative Display en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
