I want to obtain value of "W" for different combination of values of (psi,r) example. "W" for (psi=0.0001,r = 2.1891) ; (psi=0.001,r = 2.1940); (psi=0.01,r = 2.2373) and so on
1 次查看(过去 30 天)
显示 更早的评论
psi = 0.001;
alpha = (12*psi)^(1/3);
r = 2.1940;
l1 = (r + alpha)*(r + alpha);
l1a = r*r - r*alpha + alpha*alpha;
L1 = log(l1/l1a);
t1 = (2*r - alpha) / (alpha*sqrt(3));
T1 = atan(t1);
l2 = (1 + alpha)*(1 + alpha);
l2a = (1*1) - (1*alpha) + (alpha*alpha);
L2 = log(l2/l2a);
t2 = (2*1 - alpha) / (alpha*sqrt(3));
T2 = atan(t2);
W1 = 4 * sqrt(3) * (T1 - T2) * log((r+alpha)/(1+alpha));
W2 = (L1 - L2)*log((r*r - r*alpha + alpha*alpha)/(1 - alpha + alpha*alpha));
W3 = 4*(T1 -T2)*(T1 -T2);
W4 = (L1 - L2) + 2 * sqrt(3) * (T1 - T2);
W5 = 3 ./ ((r - 1) * (r - 1));
W = ((W1 + W2 -W3) * W5)/W4
2 个评论
Dyuman Joshi
2022-6-22
编辑:Dyuman Joshi
2022-6-22
Make it a function and call from workspace.
%calling individually
W1=calculateW(0.0001,2.1891)
W2=calculateW(0.001,2.194)
W3=calculateW(0.01,2.2373)
function W = calculateW(psi,r)
alpha = (12*psi)^(1/3);
l1 = (r + alpha)*(r + alpha);
l1a = r*r - r*alpha + alpha*alpha;
L1 = log(l1/l1a);
t1 = (2*r - alpha) / (alpha*sqrt(3));
T1 = atan(t1);
l2 = (1 + alpha)*(1 + alpha);
l2a = (1*1) - (1*alpha) + (alpha*alpha);
L2 = log(l2/l2a);
t2 = (2*1 - alpha) / (alpha*sqrt(3));
T2 = atan(t2);
W1 = 4 * sqrt(3) * (T1 - T2) * log((r+alpha)/(1+alpha));
W2 = (L1 - L2)*log((r*r - r*alpha + alpha*alpha)/(1 - alpha + alpha*alpha));
W3 = 4*(T1 -T2)*(T1 -T2);
W4 = (L1 - L2) + 2 * sqrt(3) * (T1 - T2);
W5 = 3 ./ ((r - 1) * (r - 1));
W = ((W1 + W2 -W3) * W5)/W4;
end
采纳的回答
Dyuman Joshi
2022-6-22
%loop
psi=[0.0001,0.001,0.01];
r=[2.1891,2.194,2.2373];
for i=1:numel(psi)
W(i)=calculateW(psi(i),r(i));
end
W
%arrayfun
W1=arrayfun(@calculateW, psi, r)
function W = calculateW(psi,r)
alpha = (12*psi)^(1/3);
l1 = (r + alpha)*(r + alpha);
l1a = r*r - r*alpha + alpha*alpha;
L1 = log(l1/l1a);
t1 = (2*r - alpha) / (alpha*sqrt(3));
T1 = atan(t1);
l2 = (1 + alpha)*(1 + alpha);
l2a = (1*1) - (1*alpha) + (alpha*alpha);
L2 = log(l2/l2a);
t2 = (2*1 - alpha) / (alpha*sqrt(3));
T2 = atan(t2);
W1 = 4 * sqrt(3) * (T1 - T2) * log((r+alpha)/(1+alpha));
W2 = (L1 - L2)*log((r*r - r*alpha + alpha*alpha)/(1 - alpha + alpha*alpha));
W3 = 4*(T1 -T2)*(T1 -T2);
W4 = (L1 - L2) + 2 * sqrt(3) * (T1 - T2);
W5 = 3 ./ ((r - 1) * (r - 1));
W = ((W1 + W2 -W3) * W5)/W4;
end
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Lighting, Transparency, and Shading 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!