How to get complete curves in a plot?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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
0 commentaires
Réponse acceptée
Torsten
le 1 Mar 2023
Modifié(e) : Torsten
le 1 Mar 2023
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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Annotations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!