I'm not getting the correct result for the u, i want it in degree but the ans is not right, the plot is not smooth.
1 回表示 (過去 30 日間)
古いコメントを表示
ni = 1;
nt = 1.5;
t = 0:0.1:1.57;
oi = rad2deg(t);
u = asind((nt.*sin(oi))./ni);
ot = abs(u);
r1 = -(sind(oi-ot)./sind(oi+ot));
plot(oi,r1);
0 件のコメント
回答 (3 件)
Davide Masiello
2022 年 10 月 19 日
編集済み: Davide Masiello
2022 年 10 月 19 日
You did not give enough information to know what the end result should be, but if your interest is only to plot in degrees, then I would perform all the calculations in radians in order to avoid confusion and convert into degrees only in the plot. See below for example
ni = 1;
nt = 1.5;
t = 0:0.001:pi/2;
u = asin(nt*sin(t)/ni);
r1 = -(sin(t-abs(u))./sin(t+abs(u)));
plot(rad2deg(t),r1);
xlabel('t, $^{\circ}$','Interpreter','latex')
ylabel('$r_1$','Interpreter','latex')
0 件のコメント
Sam Chak
2022 年 10 月 19 日
To understand why it is not smooth, you need to see what causes the singularity (division-by-zero) at around
.

ni = 1;
nt = 1.5;
% t = 0:0.1:1.57;
% oi = rad2deg(t);
oi = linspace(0, 90, 9001);
u = asind(nt*sind(oi)/ni); % <-- correction to your trigonometric function
ot = abs(u);
r1 = - (sind(oi - ot)./sind(oi + ot));
plot(oi, r1); ylim([-15 15]), grid on, xlabel('o_{i} (deg)'), ylabel('r_{1}')
subplot(211)
plot(oi, sind(oi - ot)), title('sind(oi - ot)'), grid on, xlabel('o_{i} (deg)')
subplot(212)
plot(oi, sind(oi + ot)), title('sind(oi + ot)'), grid on, xlabel('o_{i} (deg)')
0 件のコメント
Walter Roberson
2022 年 10 月 19 日
oi = rad2deg(t);
u = asind((nt.*sin(oi))./ni);
You convert to degrees but then sin() which is a radian operation. You used the correct sind() in later lines.
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!