I need help with MATLAB programming. The following code graphs a ellipsoid and a line. I need to create a line that is perpendicular to the H line and tangent to the ellipsoid. I also need to plot it in the graph. Can you help me with that? % Initial Conditions w = 3; beta = deg2rad(45); I = [150; 400; 400]; w_NU = w*[cos(beta); 0; -sin(beta)] H_NU = [I(1)*w_NU(1); I(2)*w_NU(2); I(3)*w_NU(3)] T = (0.5)*dot(w_NU,H_NU); scal_c = sqrt(2*T); a = I(1)^(-1/2) * scal_c b = I(2)^(-1/2) * scal_c c = I(3)^(-1/2) * scal_c figure; [x, y, z] = ellipsoid(0, 0, 0, a, b, c); h2 = surf(x, y, z,'FaceColor', [0.8500 0.3250 0.0980]); hold on % Plotting Angular Momentum vector plot3([0 (H_NU(1)/200)], [0 0], [0 (H_NU(3)/200)], 'k', 'Linewidth', 2) text(1.7, 0, -4.5, '$$\bar{H}$$', 'Interpreter', 'latex', 'Color', 'k', 'FontSize',14); quiver3(H_NU(1)/200, 0, H_NU(3)/200, 0.01, 0, -0.01, 'k', 'LineWidth', 8); alpha(h2, 0.5); view(0, 0); zlim([-5 5]); hold off
I need help with MATLAB programming. The following code graphs a ellipsoid and a line. I need to create a line that is perpendicular to the H line and tangent to the ellipsoid. I also need to plot it in the graph. Can you help me with that?
% Initial Conditions
w = 3;
beta = deg2rad(45);
I = [150; 400; 400];
w_NU = w*[cos(beta); 0; -sin(beta)]
H_NU = [I(1)*w_NU(1); I(2)*w_NU(2); I(3)*w_NU(3)]
T = (0.5)*dot(w_NU,H_NU);
scal_c = sqrt(2*T);
a = I(1)^(-1/2) * scal_c
b = I(2)^(-1/2) * scal_c
c = I(3)^(-1/2) * scal_c
figure;
[x, y, z] = ellipsoid(0, 0, 0, a, b, c);
h2 = surf(x, y, z,'FaceColor', [0.8500 0.3250 0.0980]);
hold on
% Plotting Angular Momentum vector
plot3([0 (H_NU(1)/200)], [0 0], [0 (H_NU(3)/200)], 'k', 'Linewidth', 2)
text(1.7, 0, -4.5, '$$\bar{H}$$', 'Interpreter', 'latex', 'Color', 'k', 'FontSize',14);
quiver3(H_NU(1)/200, 0, H_NU(3)/200, 0.01, 0, -0.01, 'k', 'LineWidth', 8);
alpha(h2, 0.5);
view(0, 0);
zlim([-5 5]);
hold off
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 3 images