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.

조회 수: 2 (최근 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);

답변 (3개)

Davide Masiello
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')

Sam Chak
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)')
ans = 75.7100

Walter Roberson
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.

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by