MATLAB: Kindly find error in the code

MATLABode45

Hey all!!
I have to 2 doubly differential dependant equations using ode45 function. My code is giving me values for 1st depensant variable but not giving any value for 2nd one. Kindly help me fix my code
here is my code:
tRange = [0,10]
g = 9.8
l = 1
k = 0.00006
%x1 = diff(x,t)
[tsol, ans1] = ode45(@pend,tRange,[0.05;0;0;0])
function dYdt = pend(t,Y)
% extracting variables from Y column vaector
x = Y(1)
x1 = Y(2)
y = Y(3)
y1 = Y(4)
% some constants defined
g = 9.8
l = 1
k = 0.000051
% Four differential eqns because 2 doubly differential equations.
dxdt = x1
dx1dt = -(g/l)*x + k*y1
dydt = y1
dy1dt = -(g/l)*y - k*x1
% arranging all in column vector
dYdt = [dxdt;dx1dt;dydt;dy1dt]
end

Best Answer

Your code runs for me without error. Note that the magnitudes of columns 3 & 4 are about 1/1000 the amplitude fo columns 1 & 2, so they plot essentially as straight lines near 0. Multiplying them by 1000 will allow you to see their structure:
figure
plot(tsol, ans1.*[1 1 1000 1000])
grid
.