(Answers Dev) Restored edit
why is not equal
조회 수: 2 (최근 30일)
이전 댓글 표시
sigma_0 = 2;
theta_deg = [0, 90, 180, 270];
theta_rad = deg2rad(theta_deg);
r = 1:0.1:2;
shear_Q = zeros(length(r), length(theta_rad));
for i = 1:length(theta_rad)
theta = theta_rad(i);
ksi = 1./r;
shear_Q(:, i) = (-1/2.*sigma_0.*(1-(3.*(ksi.^4))+(2.*(ksi.^2))).*sin(2.*theta));
end
Why doesn't it give the same result for 0 and 180 degrees? or 90 and 270 . The result must be 0 for 0 and 180 degrees
답변 (1개)
Steven Lord
2024년 3월 26일
Rather than converting from degrees to radians and then computing the sine of the angle in radians, why not just use the sind function?
sigma_0 = 2;
theta_deg = [0, 90, 180, 270];
r = 1:0.1:2;
shear_Q = zeros(length(r), length(theta_deg));
shear_Q_rad = shear_Q;
for i = 1:length(theta_deg)
theta = theta_deg(i);
thetaR = deg2rad(theta);
ksi = 1./r;
shear_Q(:, i) = (-1/2.*sigma_0.*(1-(3.*(ksi.^4))+(2.*(ksi.^2))).*sind(2.*theta));
shear_Q_rad(:, i) = (-1/2.*sigma_0.*(1-(3.*(ksi.^4))+(2.*(ksi.^2))).*sin(2.*thetaR));
end
shear_Q
Of course, 2 times each of the angles in theta_deg makes the angle a multiple of 180 degrees, and the sine of an integer multiple of 180 degrees gives us 0.
shear_Q_rad
Now why are the elements of shear_Q_rad not all zero? Go ahead and type out the exact transcendental value of the constant π. Go ahead, I'll wait for you to get to the last digit. Roundoff error creeps in when you convert the angle in degrees into the angle in radians.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Function Creation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!