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 vue (au cours des 30 derniers jours)
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);

Réponses (3)

Davide Masiello
Davide Masiello le 19 Oct 2022
Modifié(e) : Davide Masiello le 19 Oct 2022
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 le 19 Oct 2022
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 le 19 Oct 2022
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.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by