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);

回答(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.

标签

Community Treasure Hunt

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

Start Hunting!

Translated by