Hi Hasan,
Let's take a look at the code.
s = tf('s');
Gp = 2 / (0.2 * s + 1); %pump
Gv = (2.2 * 10^-3) * 2; %valve
Gt = 24.2 / (3.3 * s + 1); %tank
Gl = 1; % level sensor
oltf = Gp * Gv * Gt * Gl;
%PD controller parameters
kP = 6; % Start with an initial guess for kP
TD = 0.2; % Start with an initial guess for TD
% PD controller transfer function
PD = kP * (1 + TD * s);
Assuming that the goal is to control the true level and that the level sensor is in the feedback path, the closed-loop transfer function is:
H(s) = PD(s)*Gp(s)*Gv(s)*Gt(s)/( 1 + PD(s)*Gp(s)*Gv(s)*Gt(s)*Gl(s) )
So this line should really be:
% Closed loop transfer function with PD
CLTF_PD = (PD * Gp * Gv * Gt) / (1 + PD * Gp * Gv * Gt * Gl);
Of course, with Gl(s) = 1 it doesn't really matter, but maybe you're going to change Gl(s) later. Also, transfer function algebra in Matlab is discouraged. Instead, better to get in the habit of using interconnection commands, such as feedback
CLTF_PD = feedback(PD * Gp * Gv * Gt, Gl);
Step response
figure
stepplot(CLTF_PD)
We see that the steady state error is quite a bit larger (~0.45) than the requirement (0.005), so let's start with that.
What is the expression for the final value of the output , in terms of H(s), in response to a step input ? Or alternatively, what is the expression for the final value of the error, e(t) = r(t) - y(t), in terms of H(s), when r(t) is a step input ?

