Effacer les filtres
Effacer les filtres

How Can I plot Streamlines for the following code

2 vues (au cours des 30 derniers jours)
KIRAN Sajjanshetty
KIRAN Sajjanshetty le 27 Juil 2022
Rva=[1 0.01];
for i=1:2
M= Rva (i);
lines = {':b',':g'};
lmd=1;
y=0.5;
gam=1;
N=0.0;
A=0;
B=1;
c1=(A+(B.*gam))./(1+gam);
c2=(B-A)./(1+gam);
T=c1+(c2.*y);
k1=(-N.*((A.^2)-(2.*A.*B)+(B.^2)))./((1+gam).^2);
k2=(-((2.*N.*(A.*B-(A.^2)-(A.*B.*gam)+(B.^2).*gam)+(B-A-(A.*gam)+(B.*gam)))))./((1+gam).^2);
k3=(-(N.*((A.^2)+(2.*A.*B.*gam)+(B.^2).*(gam.^2))+(A+(A.*gam)+(B.*gam)+(B.*(gam.^2)))))./((1+gam).^2);
x1=(1./(lmd.*M.*(cosh(M))+sinh(M)));
x2=((1-cosh(M)).*((2.*k1)+((M.^2).*k3))./(M.^4))+(k1+(k2.*(1+lmd.*(cosh(M)))))./(M.^2);
c4=x1.*x2;
c3=(lmd.*M.*c4)+((2.*k1+(M.^2).*k3)./(M.^4))-(lmd.*k2./(M.^2));
u=c3.*(cosh(M.*y))+c4.*(sinh(M.*y))-((k1.*(y.^2)+(k2.*y)+((2.*k1+(M.^2).*k3)./(M.^2))))./(M.^2);
t0=M.*c4-(k2./(M.^2));
t1=M.*(c3.*sinh(M)+c4.*cosh(M))-((2.*k1+k2)./(M.^2));
t=M.*(c3.*sinh(M.*y)+c4.*cosh(M.*y))-((2.*k1.*y+k2)./(M.^2));
Q=(1./M).*(c3.*sinh(M)+c4.*(cosh(M)-1))-((((M.^2)+6).*k1)./(3.*(M.^4)))-((k2+2.*k3)./(2.*(M.^2)));
k4=-(k1./(M.^2));
k5=-(k2./(M.^2));
k6=-((2.*k1+(M.^2).*k3)./(M.^4));
x3=((4.*c1.*k4)+(6.*c1.*k5)+(12.*c1.*k6)+(3.*c2.*k4)+(4.*c2.*k5)+(6.*c2.*k6))./(12);
Tb1=((c1.*c3).*(sinh(M))./M)+((c1.*c4).*(cosh(M)-1)./(M));
Tb2=((c2.*c3).*(M.*sinh(M)-(cosh(M))+1)./(M.^2));
Tb3=(((c2.*c4).*(M.*(cosh(M))-(sinh(M)))./(M.^2))+x3);
Tb=(1./Q).*(Tb1+Tb2+Tb3);
Nu0=-c2./Tb;
Nu1=c2./Tb;
S=(T+(N.*T.*T));
figure(2)
hold on;
plot(y,u, lines {i},'linewidth',2)
xlabel('Y');
ylabel('U');
box on;
hold off;
fprintf ('M=%f\t u=%f\t Q=%f\t Tb=%f\t cf0=%f\t cf1=%f\t Nu0=%f\t Nu1=%f \n ',M,u,Q,Tb,(t0),(t1),(Nu0),(Nu1));
end
  1 commentaire
KIRAN Sajjanshetty
KIRAN Sajjanshetty le 27 Juil 2022
I need to plot stream lines for U , t0,t1 and Nu0,Nu1

Connectez-vous pour commenter.

Réponses (1)

Aman Banthia
Aman Banthia le 7 Sep 2023
Hi Kiran,
I understand that you are trying to plot streamlines for ‘U’,’ ‘t0’, ‘t1’, ‘Nu0’, ‘Nu1’.
The following approach can be used to plot those curves:.
  1. Add a loop: The code now includes a for loop that iterates over the values of ‘M’ in the ‘Rva’ array. This allows the code to calculate and plot the streamlines for each value of ‘M’.
  2. Update the variable y: The variable ‘y’ is now defined as a range of values from 0 to 1 with a step size of 0.01. This range determines the values of ‘y’ at which the streamlines will be calculated and plotted.
  3. Move variable calculations inside the loop: The calculations for various variables such as ‘c1’, ‘c2’, ‘T’, ‘k1’, ‘k2’, etc., are now placed inside the loop. This ensures that the calculations are performed for each value of ‘M’.
  4. Add plotting for multiple variables: In addition to plotting u, the code now also plots ‘t0’, ‘t1’, ‘Nu0’, and ‘Nu1’. Each variable is plotted with a different line style (':b' and ':g') to distinguish between different values of ‘M’.
  5. Add legend: A legend is added to the plot to indicate which line corresponds to which variable. This helps in understanding the plot and differentiating between the variables.
  6. Update the print statement: The print statement fprintf is modified to display the values of ‘M’, ‘u’, ‘Q’, ‘Tb’, ‘t0’, ‘t1’, ‘Nu0’, and ‘Nu1’ for each iteration of the loop. This provides a summary of the calculated values for each value of ‘M’.
These changes allow the code to calculate and plot the streamlines for ‘U’, ‘t0’, ‘t1’, ‘Nu0’, and ‘Nu1’ for different values of ‘M’. The loop ensures that the calculations are performed for each value of ‘M’ in the ‘Rva’ array, and the plot provides a visual representation of these variables. The legend and print statement help in understanding and analysing the results.
Hope that the above solution helps you.
Best Regards,
Aman Banthia

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by