You were creating a function, why not make that explicit?
%Pohlhausen/thwaites polynomial
%clear;clc;close;
% ^^^^^^ you don't need this
i = 1;
j = 1;
k = 1;
V = -12; %Upper case lambda
V1 = 12; %Upper case lambda
V2 = 0; %Upper case lambda
ys = 0; %y/delta - normalized y axis. delta is BL thickness (minimum)
ys1 = 0; %y/delta - normalized y axis. delta is BL thickness (minimum)
ys2 = 0; %y/delta - normalized y axis. delta is BL thickness (minimum)
%upper case lambda -12
[x,f]=myFun(i,V,ys);
%upper case lambda -12
% ^ is that correct?
[xa,g]=myFun(j,V1,ys1);
%upper case lambda 0
[xb,h]=myFun(k,V2,ys2);
figure(1),clf(1)
% ^^^^^^^
%during debugging you can add this to make sure your figure is clean
plot(x,f,'r-',xa,g,'b-',xb,h,'c-','LineWidth', 2)
%hold on
% you aren't plotting anything else, so hold on is not required
grid on
title('Pohlhausen Velocity distribution')
ylabel('u/U_\infty', 'FontSize', 20)
xlabel('y* = y/\delta','FontSize', 20)
legend('\Lambda = 12','\Lambda = -12','\Lambda = 0','location','southeast')
ylim([0 1.1])
function [x,f]=myFun(i,V,ys)
%Write documentation explaining this function here
%
%write syntax examples as well
%Do input checking and make sure any errors that can occur will trigger an
%error here, so the user can understand what they need to change.
%After this input validation step, no error is allowed to occur.
x=zeros(1,ceil((ys-1)/0.01);%pre-allocate array
f=zeros(size(x));%pre-allocate array
while ys <=1 ; %y/delta - normalized y axis. delta is BL thickness (maximum)
x(i) = ys; %range of normalize y
f(i)=(2*ys - 2*ys^3 + ys^4) + ...
((V/6*ys)*(1-ys)^3); %u/U_infinity - pohlhausen velocity distribution
ys = ys + 0.01; %step of normalize y
i = i+1; %array step
end
if numel(x)>i
%remove padding
x(i+1:end)=[];
f(i+1:end)=[];
end
end