how can I do Iteration in matlab
Mostrar comentarios más antiguos
I have an equation of the form
a(x) + x.da/dx = 2x , x= 1:1:12
f(x) is known and has different values for different x. My question is how can I find values of 'a' in matlab through iteration. Am new to matlab and any help is highly appreciated.
Respuesta aceptada
Más respuestas (1)
Azzi Abdelmalek
el 17 de Nov. de 2012
Editada: Azzi Abdelmalek
el 17 de Nov. de 2012
save this funnction with the name dif_eq
function da=dif_eq(x,a)
f=sin(x); for example
da=(f-a)/x;
then type in Matlab command
[x,res]=ode45(@dif_eq,[1 12],0)
5 comentarios
Ede gerlderlands
el 17 de Nov. de 2012
Azzi Abdelmalek
el 17 de Nov. de 2012
Editada: Azzi Abdelmalek
el 17 de Nov. de 2012
You said that f is a function of x, then replace in my code, f=sin(x) by your own function
The code I did solves your differential equation
Ede gerlderlands
el 17 de Nov. de 2012
Ede gerlderlands
el 17 de Nov. de 2012
Azzi Abdelmalek
el 17 de Nov. de 2012
Ede, the problem is not a, we are looking for a. I can't use f with different values in the equation. If I find something I will post it, or someone else will do.
Categorías
Más información sobre Ordinary Differential Equations en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!