Forward Kinematics for articulated manipulator not giving right answer

I calculated the forward kinematics for an articulated manipulator robot in ROS, but I am not getting the right answer. Here is the diagram for the robot configuration I used-

When Q1,Q2,and Q3 are zero this calculation is supposed to give the dx,dy and dz as 2,0,1 if I consider all the link lengths as 1.But after I substitute these values of Q1=0,Q2=0, and Q3=0 I get dx,dy, and dz as 2,0,0. I double checked the DH parameters and calculations in Matlab, but the values are still 2,0,0. I am not sure why I am not getting the right answer. Maybe I am getting the right answer, but I don't understand it.

My Matlab calculation after substituting Q1, Q2,and Q3 as 0,0,0-

>> a1

a1 =

1     0     0     0
0     0    -1     0
0     1     0     0
0     0     0     1

>> a2

a2 =

1     0     0     1
0     1     0     0
0     0     1     0
0     0     0     1

>> a3

a3 =

1     0     0     1
0     1     0     0
0     0     1     0
0     0     0     1

>> t06=a1*a2*a3

t03 =

1     0     0     2
0     0    -1     0
0     1     0     0
0     0     0     1

>>


In my inverse kinematics code when I enter the coordinates of end effector as 2,0,1, I get correct Q values i.e 0,0,0 or 0,0,2Pi. Where am I going wrong?

You have drawing that shows some vertical distance $$d_1$$ between your first and second frames:
but on your table you don't have any values for $$d_1$$:
You didn't show how you built up your matrices, so I can't tell you how/where exactly you went wrong, but I strongly suspect you've dropped your $$d_1$$ distance. This is what's setting your elevation, so it makes sense to me that you're getting $$z=0$$ when $$d_1=0$$.
• In reading through everything again after posting the answer, you're calling the other links $a_2$ and $a_3$, which are in your table, but the $F_0$ to $F_1$ distance is $d_1$ and again the table shows zeros for both $a_1$ and $d_1$.