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.

 채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2012년 11월 17일
편집: Azzi Abdelmalek 2012년 11월 17일

0 개 추천

save this function with the name dif_eq
function da=dif_eq(x,a,tim,f)
f1=interp1(tim,f,x)
da=(f1-a)/x;
then call the function:
t=[0.1:10]; % time vector
x0=0; % initial condition
f=rand(1,numel(t)); % your vector f, same length as vector time t
[X,A]=ode45(@(x,a) dif_eq(x,a,t,f),t,x0);
plot(X,A)

댓글 수: 1

Ede gerlderlands
Ede gerlderlands 2012년 11월 17일
Many many thanks ...don't have words for your help....this was so troublesome...

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Azzi Abdelmalek
Azzi Abdelmalek 2012년 11월 17일
편집: Azzi Abdelmalek 2012년 11월 17일

0 개 추천

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

Ede gerlderlands
Ede gerlderlands 2012년 11월 17일
Thanks Azzizi can you clarify me how can I insert the 'f' value in my command and the second is this equation can solve the differential part of the equation. My equation is a(x) + x.da/dx = f(x),
Azzi Abdelmalek
Azzi Abdelmalek 2012년 11월 17일
편집: Azzi Abdelmalek 2012년 11월 17일
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
Ede gerlderlands 2012년 11월 17일
Yes, I did that my actual 'f' is not function actually it is collection of different values. such as 0.4 0.25 0.6.....
Ede gerlderlands
Ede gerlderlands 2012년 11월 17일
Thanks Azziz , I understand your function but 'a' itself isn't known and that's my problem.
Azzi Abdelmalek
Azzi Abdelmalek 2012년 11월 17일
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.

댓글을 달려면 로그인하십시오.

카테고리

제품

Community Treasure Hunt

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

Start Hunting!

Translated by