How to get different values of Wbar, Fbar and fbar for different values of r and psi like for psi = [0.0, 0.0001] and similarly for 'r'.

조회 수: 2 (최근 30일)
k = 1:21;
Hbar=0.04; % A:Length of bearing, H:Bearing wall thickness, Hbar = H/A
r= 1.7773; % Film thickness ratio
psi=0.0; % Permeability parameter
calpha = ((k.^2).*(pi^2).*(1+r+r.^2+r.^3))+3*(1-r-r.^2+r.^3);
y = 1./((k.^2).*((48.*k.*pi.*psi.*tanh(k.*pi*Hbar))+(Hbar*calpha)));
x = 192*0.04*(r-1)/pi^2;
Wbar = x*sum(y) % Dimensionless load capacity
z = log(r)/(r-1);
t = 96*0.04*(r-1)^2/pi^2;
Fbar = z+t*sum(y) % Dimensionless friction drag exerted by a moving slider
fbar = Fbar/Wbar % Coefficient of friction

답변 (1개)

Balavignesh
Balavignesh 2023년 9월 22일
Hi Avinash,
I understand that you want to get different values of the result variables ("Wbar, "Fbar", "fbar) for different values of psiand r. You can store the required values of “psi” and “r” you want to experiment in two different arrays. You can then initialize three different result arrays “Wbar”,Fbar”,fbar” and use a “for” loop to update the result arrays for different values of psi and r. The following code snippet may help you achieve this:
r= [1.7773 , 1.234 , 1.678]; % Film thickness ratio
psi= [0.0 , 0.001 , 0.002] ;% Permeability parameter
Wbar = []; %initalizing a result array
for i = 1:3
calpha = ((k.^2).*(pi^2).*(1+r(i)+r(i).^2+r(i).^3))+3*(1-r(i)-r(i).^2+r(i).^3);
y = 1./((k.^2).*((48.*k.*pi.*psi(i).*tanh(k.*pi*Hbar))+(Hbar*calpha)));
x = 192*0.04*(r(i)-1)/pi^2;
Wbar(i) = x*sum(y) % updating each index of result array using for loop
end
You can refer to the Mathworks Documentation link below to get more information about "for" loops:

카테고리

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