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.
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)