how to correctly get values for stress for Y >82 values should be close to zero at Y = 88.25
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Joel Rebello
le 7 Oct 2020
Commenté : Joel Rebello
le 7 Oct 2020
p = -100;
y = 0:0.25:88.25;
l = 1:1:199;
ybar = 63.17;
i = 790200.11;
t = 88.25;
[L,Y,P] = meshgrid(l,y,p);
V = p.*L;
Q1 = -3.125.*(Y.^2) + 394.81.*Y;
Q2 = -82.8.*(((Y.^2)/2)-63.17.*Y)-139163.72;
if Y >= 82
stress = abs(V.*Q2)/(i*t);
else
stress = abs(V.*Q1)/(i*t);
end
contourf(L,Y,stress);
Réponse acceptée
Asad (Mehrzad) Khoddam
le 7 Oct 2020
You can use vectorized if statement:
Q = Q2 .* (Y >= 82) + Q1 .* (Y < 82);
stress = abs(V.*Q)/(i*t);
4 commentaires
VBBV
le 7 Oct 2020
The results produced however may not be correct.
Asad logic produces results by adding the stress vector. which may not be correct
See the difference in two results attached. if you use for loop instead
clc; clear all ;
p = -100;
y = 0:0.25:88.25;
l = 1:1:199;
ybar = 63.17;
i = 790200.11;
t = 88.25;
[L,Y,P] = meshgrid(l,y,p);
V = p.*L;
Q1 = -3.125.*(Y.^2) + 394.81.*Y;
Q2 = -82.8.*(((Y.^2)/2)-63.17.*Y)-139163.72;
[R C] = size(Y)
for i = 1: R
for j = 1: C
if Y(i,j) >= 82
stress(i,j) = abs(V(i,j)*Q2(i,j))/(i*t);
else
stress(i,j) = abs(V(i,j)*Q1(i,j))/(i*t);
end
end
end
contourf(L,Y,stress);
Plus de réponses (1)
KSSV
le 7 Oct 2020
You have to use logical indexing to achieve this.
clc; clear all ;
p = -100;
y = 0:0.25:88.25;
l = 1:1:199;
ybar = 63.17;
i = 790200.11;
t = 88.25;
[L,Y,P] = meshgrid(l,y,p);
V = p.*L;
Q1 = -3.125.*(Y.^2) + 394.81.*Y;
Q2 = -82.8.*(((Y.^2)/2)-63.17.*Y)-139163.72;
stress = zeros(size(L)) ;
stress(Y>=82) = abs(V(Y>=82).*Q2(Y>=82))/(i*t);
stress(Y<82) = abs(V(Y<82).*Q2(Y<82))/(i*t);
contourf(L,Y,stress);
0 commentaires
Voir également
Catégories
En savoir plus sur Stress and Strain dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!