# how to correctly get values for stress for Y >82 values should be close to zero at Y = 88.25

조회 수: 4(최근 30일)
Joel Rebello 2020년 10월 7일
댓글: Joel Rebello 2020년 10월 7일
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);
##### 댓글 수: 5표시숨기기 이전 댓글 수: 4
VBBV 2020년 10월 7일
Bcoz you were not using a loop for matrix Y. Use a for loop instead instead to step thru each value of Y as
% if true
% code
%end
for i = 1: length(Y)
for j = 1: length(Y)
if Y(i,j) >= 82
...
else
...
end
end
end
contourf(...)

댓글을 달려면 로그인하십시오.

### 채택된 답변

You can use vectorized if statement:
Q = Q2 .* (Y >= 82) + Q1 .* (Y < 82);
stress = abs(V.*Q)/(i*t);
##### 댓글 수: 4표시숨기기 이전 댓글 수: 3
Joel Rebello 2020년 10월 7일
thanks vasishta, the analysis is with regards to the shear stress on a T-beam, i checked the results from the code you presented and not sure why but the contour does not represent the behaviour of the stress caused by shear (V) acting on the beam. For shear stress the stress is maximum stress should be around the neutral axix (ybar) where Y =63.17, but your results indicate the maximum value is around Y = 5.

댓글을 달려면 로그인하십시오.

### 추가 답변(1개)

KSSV 2020년 10월 7일
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);

댓글을 달려면 로그인하십시오.

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by