Generate a vector like 1,2,2,3,3,3,4,4,4,4
So if n = 3, then return
[1 2 2 3 3 3]
And if n = 5, then return
[1 2 2 3 3 3 4 4 4 4 5 5 5 5 5]
function ans = GenerateVector(n)
ans = 1;
for n = 2:n
ans = [ans n*ones(1, n)];
could sb explain me why this code is flagged a as a bad one ?? it works !! and another thign in problem definition it is not clearly stated that the solutions must be straight code without writing a function. I wrote a function and it works well to the definition of the problem. then I am getting incorrect information after submission. dear cody team: please write more specific requirements of the problem. you will miss many misunderstandings then.
Your function has to use exactly the same name that is provided in the function template. In this case, the function must be called "you_fcn_name". You wrote a function called "GenerateVector". Change the name of your function and it should pass.
The test suite has been expanded.
Funny, I just tested you SO post too, and it has 2 nodes lest without the assignment to ans. I don't get this yet...
could sb please explain me politely why this code has been rated as an incorrect one ? if you paste this in m-file it works !!!
Function name should be your_fcn_name
Given two strings, find the maximum overlap
Back to basics 5 - Clipboard
Back to basics 13 - Input variables
Return the Fibonacci Sequence
matlab indian players
Determine if input is a Narcissistic number
Repeat copies of array elements
Find the maximum two numbers of every column of a matrix
Find the right number make the equation
Compute the intersect point of line and plan
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