First, find the n nth roots of unity.
eg if n = 6, find the n distinct (complex) numbers such that n^6 = 1.
Second, raise each root to the power pi (.^pi).
Third, sum the resulting numbers and use that as the output.
Surely I shouldn't done this ugly string thing, that is bad for everyone. Without any doubt, Tim's solution is the best one
Find all elements less than 0 or greater than 10 and replace them with NaN
Convert a vector into a number
Is the input divisible by 3?
Area of a triangle
Find argmax of a function
Find left eigenvector of row stochastic matrix
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office