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 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (3)
Davide Masiello
il 19 Ott 2022
Modificato: Davide Masiello
il 19 Ott 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')
0 Commenti
Sam Chak
il 19 Ott 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)')
0 Commenti
Walter Roberson
il 19 Ott 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.
0 Commenti
Vedere anche
Categorie
Scopri di più su Annotations in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!