Generate the following vector: if n=1 then q=1; elseif n=2 then q=[2 2 1]; elseif n=3 then q=[3 3 3 2 2 1]; ... end
Solution Stats
Problem Comments
1 Comment
Solution Comments
Show comments
Loading...
Problem Recent Solvers73
Suggested Problems
-
Project Euler: Problem 1, Multiples of 3 and 5
3731 Solvers
-
Generate a vector like 1,2,2,3,3,3,4,4,4,4
14317 Solvers
-
Given a matrix, swap the 2nd & 3rd columns
1284 Solvers
-
249 Solvers
-
4738 Solvers
More from this Author1
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
Your test suite is a bit strict --- it's too easy for the letters "if" to appear somewhere in your script, say when you pass ..., "UniformOutput", false to arrayfun. (Good thing you can abbreviate it there.)