(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!