clc
clear
%discretize the space based on uniform spacing(eta)
eta = 0.02;
N = 300;
%specific the slope of second derivative(f'') of velocity profile(alpha)
Alpha = [0.29 0.31 0.3321 0.35 0.37];
%initialize variables(f1,f2 and f3 are the 1st,2nd & 3rd derivatives of f
%respectively)
hold on
for k = 1:numel(Alpha)
alpha = Alpha(k);
f = zeros(N,1);
f1 = zeros(N,1);
f2 = zeros(N,1);
f3 = zeros(N,1);
%apply boundary conditions
f(1) = 0;
f(2) = 0;
f(3) = (eta^2)*alpha;
f2(1) = alpha;
%solution loop(solving for f and its derivatives as eta increases)
for i = 2:N
f(i+2) = 3*f(i+1)-3*f(i)+f(i-1)-(eta/2)*f(i)*(f(i+1)+f(i-1)-2*f(i));
f1(i) = (f(i+1)-f(i))/eta;
f2(i) = (f(i+1)-2*f(i)+f(i-1))/(eta^2);
f3(i) = (f(i+2)-3*f(i+1)+3*f(i)-f(i-1))/(eta^3);
end
%plotting the solution
j = 0:eta:5.98;
plot(j,f1,'LineWidth',1)
end
point = [4.92,0.99];
plot(point(1),point(2),'o','MarkerFaceColor','blue','MarkerSize',6)
hold off
grid on