I need help with MATLAB programming. I have create 2 matrices eta_1 and eta_2 from eta1 and eta2. I am trying to intersect each column of eta_1 with each column of eta_2 as you can see in the last for loop. But the code only lets me intersect until the index hits 4. At index 5 it shows an error. I don't know why it would work for the first four indeces and stop at i = 5. Can you help me fix it? eta1 = [135.3767 136.7215 138.0672 139.4093 140.7436 142.0707 143.3915 144.7063 146.0159]; eta2 = [-44.6233 -43.2785
I need help with MATLAB programming. I have create 2 matrices eta_1 and eta_2 from eta1 and eta2. I am trying to intersect each column of eta_1 with each column of eta_2 as you can see in the last for loop. But the code only lets me intersect until the index hits 4. At index 5 it shows an error. I don't know why it would work for the first four indeces and stop at i = 5. Can you help me fix it?
eta1 = [135.3767 136.7215 138.0672 139.4093 140.7436 142.0707 143.3915 144.7063 146.0159];
eta2 = [-44.6233 -43.2785 -41.9328 -40.5907 -39.2564 -37.9293 -36.6085 -35.2937 -33.9841];
% For cos
eta_1 = [abs(eta1); 360-abs(eta1)];
% For sin
for i = 1:length(eta2) % Fix the loop indexing
if 0 <= eta2(i) && eta2(i) <= 180
eta_2(1,i) = eta2(i);
eta_2(2,i) = 180 - eta2(i);
elseif 180 < eta2(i) && eta2(i) <= 360
eta_2(1,i) = eta2(i);
eta_2(2,i) = 360 - (eta2(i) - 180);
elseif -360 < eta2(i) && eta2(i) <= -180
eta_2(1,i) = 360 + eta2(i);
eta_2(2,i) = 180 - (360 + eta2(i));
elseif -180 < eta2(i) && eta2(i) <= 0
eta_2(1,i) = 360 + eta2(i);
eta_2(2,i) = 360 - (180 - eta2(i));
end
end
eta_1
eta_2
for i = 1:length(eta_1)
eta(i) = intersect(eta_1(:,i), eta_2(:,i))
end
Step by step
Solved in 6 steps with 4 images