Hi,
I am trying to solve a second-order nonlinear equation (in terms of [zz,xx] where 'zz' is independent variable and xx is to solved) which contains a 2D vector [R_p], whose current position [R_p(zz,xx(1))] is called inside the differential equation. Here is the code
close allr = [0:.1:20];z = [20:.1:30];rz = zeros(length(r),length(z));for n=1:length(z) w = w0*sqrt(1+(z(n)/zR).^2); Gau = a0 .* exp(-(r-(max(r)/2)).^2/(2*w)); rz(:,n) = Gau; n=n+1;end[Z_p,R_p] = gradient(rz);f = @(zz,xx) [xx(2); -R_p(zz,xx(1))* sin(xx(1))*(xx(1))^2 + (1-xx(2))];ode45(f,z,[1;0])
R_p is basically a 2D vector along zz and xx direction. In each integration step, the value of R_p depends on the current (or the pervious) value of zz and xx.
This doesn't seem to work. Please help me to solve this problem. If one removes R_p(zz,xx(1)), the code seems to work just fine.
Ajay
Best Answer