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.
Is there any way to avoid the for loop? I really want to but I don't see how right now.
Good one! took some time but finally did it.
Can it be done without a for loop?
use command "repelem"
great problem. Interesting for beginners like me.
can we do it without loops?
Incredibly fun problem!
Easy and funny
Great and funny
Looks tricky.. but easy one
Seems like all the "winning" solutions are using regexp to hide algorithm complexity. Really need a truer way to evaluate "best" solutions - for example classic "tic" "toc".
The suggestion leads to wrong answers because of "ans".
It would be nice to know how the leading solution was do to be so small.
My solution size is at least 6 times than the leading solution. I would like to be enlightened...
what's wrong with my answer? it gives exactly the right answer just not in 
also the test suite says it gives you x but when you use x in the function it doesn't recognize x you have to use n
Brilliant solution without using loops.
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...
neat and elegant.
didn't even known about Henkel's matrix
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
Project Euler: Problem 3, Largest prime factor
Back to basics 4 - Search Path
Sophie Germain prime
Find the next prime number
Matlab Basics - Absolute Value
Project Euler: Problem 14 Longest Collatz sequence(harder version)
Make an anonymous function that has variable output
Return fibonacci sequence do not use loop and condition version 2
Big Integer Sqrt
Find the treasures in MATLAB Central and discover how the community can help you!
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