Your code:

Code:

h=pi/8 %step value (seconds)
y=pi/4 %initial value
x=pi/4 %intial value
for i=1:1:10
f=inline('y + (2.*(x.^2).*cos(2.*x))./x','s')
g=f(y,x)
y= y + f(y,x)*h
x=x+(pi/8)
end

1. Take the inline declaration out of the loop

2. Always explicity declare the vatiable names in the inline.

3. Remove all lines that do nothing.

4. Do not use a variable to hold a value then explicity code that value somewhere, use the variable.

So lets try:

Code:

h=pi/8 %step value (seconds)
y=pi/4 %initial value
x=pi/4 %intial value
f=inline('y + (2.*(x.^2).*cos(2.*x))./x','y','x');
for i=1:1:10
y= y + f(y,x)*h;
x=x+h;
end

CB