Nice problem
nice
This is very easy thing
Great!
nice
Easy problem! Great!
Love it!
nice
Very interesting!
Great beginner problem!
nice
nice
nice
nice
nicer
nice
great
good start
very good
1:10
the solution is well used by day to day users in matlab
a=1:10
[1:1:10]
It is so easy.Don't you think?
what is difference between 123456 and 1 2 3 4 5 6 vectors?
good
Yeah, I personally like the colon operator for creating vectors!
@Muhammad Tanveer: if you take 123456 (without commas, semicolons or spaces), it is one (huge) number.
You can create a vector both by enclosing the elements in square brackets like v=[1 2 3 4 5] or using commas, like v=[1,2,3,4,5]. They mean the very same: a vector (matrix) of 1 row and 5 columns. It is up to you.
If you used a semicolon (;), then v=[1;2;3;4;5] means something else: a vector of 5 rows and one single column.
awesome!
awesome!
awesome!
awesome!
awesome!
awesome!
Great idea to learn colon notation! Thanks!
cool
Why did I copy the code to the matlab editor and run it but the command line window says I didn't define a function or variable?
Easy ;)
good
easy stuff
i need more points
link is very helpful
good problem.
GOOD
it's magic ^_^
easy
Well crafted problem!
super
great problem
you are sooo right
Easy way to learn concatenation :)
easy
very easy
How come?
linspace gives you a smaller size :)
is it ok
Great problem
wow very fun!
[1:1:10]
why not
Nice. What is the difference between this vector and x = linspace(1,10,10)?
Hello Matthew Jones,
Linspace is similar to the colon operator ":", but gives direct control over the number of points.
In x = linspace(1,10,10) you directly enter the number of points and the function generates equally spaced vector but when you use ":" operator, you need to mention step size.
.
good job
This user (mohamed elbesealy) appears to have gamed the system, with fraudulent "likes" of this unremarkable solution submitted by 'sock-puppet' accounts. —DIV
This user (ALBERT ALEXANDER STONIER) appears to have gamed the system, with fraudulent "likes" of this unremarkable solution submitted by 'sock-puppet' accounts. —DIV
i really don't get why it is wrong lol
try again you are so best
This really saves time!
what about x = 1:10;
im also wondering why ' x=1:10' doesn't work
no,it works
try it without using ' ' (x = 1:10;)
Nice!
I have tried multiple things that would create that vector, and it won't accept my answer. I am not sure what this question wants from me I guess.
The output of your function is x, not x_correct, so remove "_correct" and it should work.
remove the square brackets,size will reduce even more
why isnt the [] notation required for the solving of the puzzle?
how do you improve on this solution?
Shorter than mine.
ermmm why not? It works when I type it in...
Please help!!!!not sure where i went wrong
You just need to type x=[1,2,3,4...10] or x=1:10
Just edit that line in the code. Not the whole thing
You should name the function exatly 'oneToTen',and apparently,your x is from 1 to 9,not 1 to 10.
x=1:10 do the same.
I do not deem that these problems can enhance one's performance.....
This question could have been a bit more challenging.
why is this incorrect?
You need to insert "function x=oneToTen" as the first line of your function.
give a value of y simple calling the function oneToTen. it will definitely work
I do not understand the point of Cody... I cannot use "eval 1:10;" but I can use "str2num 1:10;" which is overhead + eval 1:10... Please make Cody evaluate the functions used in submitted code
what's the "str2num" mean?
str2num means "convert string to number"; even more cryptic is the fact that "str2num 1:10" is equivalent to "str2num('1:10')" (Matlab allows you to omit the single quotes and parentheses when using functions that take character strings as arguments).
please unlock the solution
I’ve found that the huge strength of MATLAB is that it frees me to rapidly prototype numerical math problems – before I design a targeted solution. Such esoteric efficiencies as above are very clever and much credit goes to the person who presented it, however, this distracts rather than adds significant value to my use of MATLAB. Depending on the target machine (Desktop workstation or embedded device) I will ultimately use C/C++, assembly and VHDL to implement my process efficient code – never an interpreted language.
This is an update since I had one person ask about my post...
I believe that speed is only one metric of performance, another is memory utilization. The key in this problem is the “type” of the variable stored internally. By using ans=1:10; the variable ans is (I believe) of the type double precision floating point (8 Bytes for each number). On the other hand by using str2num, a cast to an array of Characters (1 Byte each) is used to tightly store the tiny integer range of numbers needed. Thus the memory required to store ans is 8 times less.
SO, I’m not sure how they actually score (or weight) the importance between memory efficiency and execution time (and across multiple platforms and OS’s) since in your case you claim a faster execution time without the casting. This would need to be asked to a Mathworks person with specific insight to their code – sorry.
And back to my soapbox point… I’m using a machine that has 12 GB of RAM, so the difference between using 10 bytes or 80 bytes is not important to me.
HOWEVER, understanding this issue IS important so my hat is off to the Cody folks for the great (and fun) challenge!
Hope that helps!
john
The metric used to evaluate the performance of a solution is http://www.mathworks.com/matlabcentral/fileexchange/34754-calculate-size
As you can see if you inspect the code, it has nothing to do with speed or memory. That is why I proposed this solution, in order to show that you can become the leader with a code that is not efficient at all, either in execution speed or in memory use. Although I think the idea of Cody is great and challenging I believe that the metric that is used nowadays should be rethought.
interesting
Cannot be reproduced, creates an error in execution in R2016a.
cumsum(ones(1,10))
3660 Solvers
353 Solvers
Omit columns averages from a matrix
537 Solvers
398 Solvers
311 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!