Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
How to make homework more fun: Matlab to Ruby (coderwall.com)
46 points by bitsweet on Oct 7, 2013 | hide | past | favorite | 25 comments


Or you could just use Octave, which is an open-source Matlab clone that has almost all its core features:

https://www.gnu.org/software/octave/


Octave is good if you have to write matlab compatible code (or just like matlab and don't have access to it).

The new kid on the block Julia[1] is actually pretty nice and as someone who has written a lot of matlab code is quite similar and easy to learn.

If you don't need or want syntax similar to matlab python+scipy+numpy+matplotlib is pretty great.

I was stuck with matlab for most of my work though because of simulink+control systems toolbox and preexisting codebase.

[1]: http://julialang.org/


> If you don't need or want syntax similar to matlab python+scipy+numpy+matplotlib is pretty great.

Yes, Python is a great alternative here. Especially for more complex computations, the advantages of a very well designed generic language play very well with the specialized math stuff.


As an aside, I hope that one day something like Octave/Gnuplot for Android will let us finally be rid of the anachronistic TI-84, which only still exists because of a dirty relationship with the educational establishment.


As a mathematics educator at a community college I fully agree with your sentiment. However, faculty tend to dislike the use of smartphones or tablets as calculators since one can have notes on the device and use the internet. I personally have banned all calculators, notes, and tablets during quizzes. I require my students to Mathematica for take home assignments. They do not pay extra for Mathematica as we have a site license.

The TI-84 should not exist at all. It is underpowered and way overpriced. I think it is still used since students pay for the devices and not faculty. Institutional lethargy is at play.


My wife teaches high-school math. Course material and textbooks contain step-by-step instructions for a TI-83+, and they have class sets of the darned things.

This zombie hardware is thoroughly entrenched.

At the very least if the lessons targeted MatLab, we could see OSS implementations like Octave. But all the TI emulators still rely on pirated TI firmware.


In addition to Octave, PARI/GP and Singular should be mentioned, especially for number theory and algebraic computations:

http://pari.math.u-bordeaux.fr/

http://www.singular.uni-kl.de/


Agreed. My thesis work is entirely within Octave. It gets the job done, and anyone anywhere can review my work.

Some of MATLAB's toolkits are very nice, but day-to-day work is easily covered by Octave.


Octave is GNU, and the GNU project prefers to speak of free software than open source:

http://www.gnu.org/philosophy/open-source-misses-the-point.h...

The philosophical distinction matters a lot to me. I don't work on Octave because I think this is a better development model. I work on it because I think we should all be free to read and share our code and our algorithms.


Along the same vein whenever I'm doing my physics homework I like to take the sample code whether it's R, Matlab,c etc. And convert it to python/numpy/scipy. I find I get a much deeper understanding that way and working with ipython notebook is a great workflow for prototyping.


I never did find a solution to the performance problem when it comes to writing numeric code in Ruby. I ended up doing most of my Matlab-suggested assignments in Python with numpy instead.


I used to do a lot of scientific programming in ruby. I got around the slowness of the interpreter by generating C code on the fly. You don't have to give up Ruby as the DSL and utility language. It's the best of both worlds, if you can invest the time to set up the code generating machinery.

As I posted on the coderwall discussion: If you are working with continuous systems (ODEs) or hybrid systems (ODEs plus discrete state transitions and dynamic dataflow networks), then you might be interested in RedShift. For example, here's a simulation of a simple thermostat controller: https://github.com/vjoel/redshift/blob/master/examples/therm.... (I am the author of RedShift. You can find my RubyConf 2009 presentation on the confreaks site.)


As far as I have oberseved, Python is more widely used than Ruby as a scientific tool.

The reasons are great libraries like numpy, scipy and sympy (for symbolic expressions). Also, I think the standard library of Python is better designed more consistent.


Didn't realize Python had so much to offer for scientific and numerical usage. I'm definitely going to have to check that stuff out. Thanks!


SciRuby is not on par with alternative such as NumPy/SciPy and Octave, but NMatrix (its linear algebra lib) seems to be nice: https://github.com/SciRuby/nmatrix


FreeMAT is a really good OS clone of Matlab.

http://freemat.sourceforge.net/


If the OP was able to run his homework files just by monkeypatching a few classes, I think that shows requiring Matlab for the assignment was massive overkill. Unless you're using the toolboxes (which they weren't), what does Matlab give you that you can't get in free language?


I'm in engineering and only at the very very end on some "advanced" Control Systems classes did we even touch the toolboxes.

Everything else, from Numerical Methods to Vibrations to lab report creation would've been handled by IPython and pylab much better. I envy upcoming generations tbh.


For whatever language(s) you choose to base your course curricula around, you have to have a progression from "hello world" type exercises, to moderately complicated, and on to "go and make a thing"


This was the original intent of my professor by assigning us this exercise. As a developer, I'm not her typical electrical engineering student though


And you decided to go be awesome. Which is awesome.


Your homework is weird, because you are just evaluating a function instead of evaluating Maxwell's equations. Check out FDTD.


Matlab and several related programming languages are designed for carrying out mathematical calculations. Ruby is designed to be a multi-purpose language that has found a niche in Web-development. My advice is to use the right tool for the job, and not to try and force a round cylinder into a square hole.


Nah - use whatever tools you enjoy. This assignment doesn't look particularly numerically-demanding, and it looks like Ruby handles it fine.


I agree. I really enjoy Ruby and it made my homework assignment much more fun so that's why I went with it. Obviously has its limitations.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: