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 view (last 30 days)
Show older comments
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 Comment
Dyuman Joshi
on 22 Sep 2023
Look into Vectorization - https://in.mathworks.com/help/matlab/matlab_prog/vectorization.html
Answers (1)
Balavignesh
on 22 Sep 2023
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 Comments
See Also
Categories
Find more on Data Import and Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!