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'.
조회 수: 1 (최근 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
Dyuman Joshi
2023년 9월 22일
Look into Vectorization - https://in.mathworks.com/help/matlab/matlab_prog/vectorization.html
답변 (1개)
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 “psi” and “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:
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Import and Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!