Given n, your output should be a vector y of numbers such that the first number is 1 and the numbers following it alternate between 0 and 1. Thus,
if n = 10, then y = [1 0 1 0 1 0 1 0 1 0]
if n = 5, then y = [1 0 1 0 1]
Back to basics 8 - Matrix Diagonals
Return unique values without sorting
Whether the input is vector?
Will there be a new leader?
Replicate elements in vectors (★★★)
Extract leading non-zero digit (★★★★★)
Create a vector of the first n odd numbers (★)
Prime number check (★★)
Create logarithmically spaced values (★)
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