I need help with MATLAB programming. I was working on a program that would give the both values of sin(angle) and cos(angle). For example, if you have eta = 30 degrees. For cosine, cos(30) = cos(330). For sine, sin(30) = sin(150). My program would give you two different sets of angles when you input one set of angles. If you input 30 degrees in cos, my program would give you 30 and 330 as the result.  I am getting a problem when I try to do that for sin though. In the following program everything runs smoothly but my angle eta2 only gives two different sets of angle for the first angle I inputted. The second set to the ninth set of angle for eta2 are incorrect. Can you help me fix the problem? 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 eta1 = [abs(eta1); 360-abs(eta1)];   % For sin for i = length(9)     if 0 <= eta2(i) && eta2(i) <= 180         eta2(1,i) = eta2(i);         eta2(2,i) = 180 - eta2(i);     elseif 180 < eta2(i) && eta2(i) <= 360         eta2(1,i) = eta2(i);          eta2(2,i) = 360 - (eta2(i) - 180);          elseif -360 < eta2(i) && eta2(i) <= -180          eta2(1,i) = 360 + eta2(i);         eta2(2,i) = 180 - (360 + eta2(i));          elseif -180 < eta2(i) && eta2(i) <= 0         eta2(1,i) = 360 + eta2(i);         eta2(2,i) = 360 + (180 - eta2(i));         end end eta1 eta2 % The first column of eta2 is correct. But starting from the second to the ninth column, it is incorrect.  % There might be a problem with the for loop.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

I need help with MATLAB programming. I was working on a program that would give the both values of sin(angle) and cos(angle). For example, if you have eta = 30 degrees. For cosine, cos(30) = cos(330). For sine, sin(30) = sin(150). My program would give you two different sets of angles when you input one set of angles. If you input 30 degrees in cos, my program would give you 30 and 330 as the result. 

I am getting a problem when I try to do that for sin though. In the following program everything runs smoothly but my angle eta2 only gives two different sets of angle for the first angle I inputted. The second set to the ninth set of angle for eta2 are incorrect. Can you help me fix the problem?

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
eta1 = [abs(eta1); 360-abs(eta1)];

 

% For sin
for i = length(9)

    if 0 <= eta2(i) && eta2(i) <= 180
        eta2(1,i) = eta2(i);
        eta2(2,i) = 180 - eta2(i);

    elseif 180 < eta2(i) && eta2(i) <= 360
        eta2(1,i) = eta2(i); 
        eta2(2,i) = 360 - (eta2(i) - 180);
    
    elseif -360 < eta2(i) && eta2(i) <= -180 
        eta2(1,i) = 360 + eta2(i);
        eta2(2,i) = 180 - (360 + eta2(i));
    
    elseif -180 < eta2(i) && eta2(i) <= 0
        eta2(1,i) = 360 + eta2(i);
        eta2(2,i) = 360 + (180 - eta2(i));
   
    end

end

eta1
eta2

% The first column of eta2 is correct. But starting from the second to the ninth column, it is incorrect. 

% There might be a problem with the for loop.

Expert Solution
steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Knowledge Booster
Processes of 3D Graphics
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education