ITEC 2600 Study Guide - Quiz Guide: Cartesian Coordinate System, MatlabExam
Course CodeITEC 2600
This preview shows half of the first page. to view the full 2 pages of the document.
ITEC2600 in-Class Exercises X.Zhou York University
Introduction to Analytical Programming
Lab Exercise ♯4
1. Redo all examples from the lecture.
2. Write a user-deﬁned function for the examples (Find sums and products).
3. Write a MATLAB script ﬁle, it ﬁrst generate a random integer nranging from 3 to 15, then ask user
input nnumbers, and output the largest and smallest number.
–Re-write ﬁnding largest and smallest number as User-deﬁned function.
–Include the error-checking for user’s input.
–Re-Write a MATLAB script ﬁle to implement above by calling your function.
4. Generate a 1-by-100 vector vwhose elements are random integers ranging from 51 to 149. Write your
MATLAB script to ﬁnd the indices of all elements in vector vthat are greater or equal to 100. Then
re-write as a function by taking vector vas input argument.
5. Write a script that produces the following output. The script should iterate from 1 to 9 to produce the
expressions on the left, perform the speciﬁed operation to get the results shown on the right, and print
exactly in the format shown here.
1×8 + 1 = 9
12 ×8 + 2 = 98
123 ×8 + 3 = 987
1234 ×8 + 4 = 9876
12345 ×8 + 5 = 98765
123456 ×8 + 6 = 987654
1234567 ×8 + 7 = 9876543
12345678 ×8 + 8 = 98765432
123456789 ×8 + 9 = 987654321
6. A vector can be represented by its rectangular coordinates xand y, or by its polar coordinates rand q.
For positive values of xand y, the conversions from rectangular to polar coordinates in the range from
0 to 2πare r=px2+y2and q=arctan(y/x). The function for arctan is atan. Write a user-deﬁned
function recpol to receive as input arguments the rectangular coordinates and return the corresponding
You're Reading a Preview
Unlock to view full version