Question
The objective of this MATLAB assignment is to get you more comfortable using multi-dimensional arrays and for loops. For this assignment, please find the intercept
The objective of this MATLAB assignment is to get you more comfortable using multi-dimensional arrays and for loops. For this assignment, please find the intercept of the function y = tan(x) and a circle of various radii. Only focus on the first quadrant. Figure 1 shows the intercepts to solve for.
Your result should return a 3x5 array (or 5x3). For simplicity, use the function fzero to find the intercepts. We have provided you with approximations (which you will need when using fzero) for all the intercepts in the attached .m file. Hints Write a function that takes two inputs (a radius and an approximation for fzero) and returns the intercept as an output. This will enable you to loop through different radii. Divide the problem into 3 instances. For each instance, Ive provided a different set of guesses for fzero. Due to the nature of fzero (and the function tan(x)), any guess thats too far from the intercept may diverge to infinity, returning an NaN error in MATLAB. As you can see in Figure 1, there are no solutions for the circles with radii 1,2 in the second instance of the tan(x) waveform (and only one solution for the 3rd instance). Return 0 if there is no intercept. In the provided list of guesses, I purposely set some guesses to 20 (so that they diverge). If you enter these guesses into fzero, you will get an NaN error. The best way to work around this is to use try and catch statements. Try and catch statements are notoriously used in coding as a way of exception handling. In this assignment, your exceptions will be the data points where no intercept exists. No credit will be given to solutions that dont use a 2D array and some sort of loop.
Useful References Fzero: https://www.mathworks.com/help/matlab/ref/fzero.html Try/Catch: https://www.mathworks.com/help/matlab/ref/try.html
?,2) ?,6) ?,2) ?,6)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started