How to get complete curves in a plot?

조회 수: 2 (최근 30일)
Cesar Cardenas
Cesar Cardenas 2023년 3월 1일
편집: Torsten 2023년 3월 1일
Hello how can I get the plot shown based on the code below? I'm just getting two curves and would like to get the others. Any help will be appreciated. Thanks
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.3321;
%initialize variables(f1,f2 and f3 are the 1st,2nd & 3rd derivatives of f
%respectively)
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;
% similarity solution using shooting method (TABLE(I))
X = [j' f(1:N,1) f1 f2 f3];
%velocity profile (FIGURE(2))
point = [4.92,0.99];
figure(1)
plot(j,f1,'-r','LineWidth',1)
hold on
plot(j,f(1:300,1))
plot(point(1),point(2),'o','MarkerFaceColor','blue','MarkerSize',6)
grid on
hold on
%velocity profile (FIGURE(4))
figure (2)
plot(f1,j,'-r','LineWidth',1)
grid on
hold on
point = [0.99,4.92];
plot(j,f(1:300,1))
plot(point(1),point(2),'o','MarkerFaceColor','blue','MarkerSize',6)
grid on
plot([point(1), point(1)], [0, point(2)], 'k-','LineWidth',0.1) %vertical line
plot([0, point(1)], [point(2), point(2)], 'k-','LineWidth',0.1) %horizontal line
hold on

채택된 답변

Torsten
Torsten 2023년 3월 1일
편집: Torsten 2023년 3월 1일
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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by