Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today
4973Rank
2Badges
80Score

John Kotrosa submitted a Comment to Solution 126044

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

on 5 Dec 2012

John Kotrosa submitted Solution 164505 to Problem 167. Pizza!

on 19 Nov 2012

John Kotrosa received Commenter badge for Solution 126044

on 19 Nov 2012

John Kotrosa submitted a Comment to Solution 126044

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.

on 19 Nov 2012

John Kotrosa received Solver badge for Solution 164453

on 19 Nov 2012