

How to make homework more fun: Matlab to Ruby - bitsweet
https://coderwall.com/p/b3ofig

======
Kronopath
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/](https://www.gnu.org/software/octave/)

~~~
FireBringer
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/](http://julialang.org/)

~~~
vog
_> 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.

------
whitewhim
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.

------
adambard
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.

~~~
vjoel
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...](https://github.com/vjoel/redshift/blob/master/examples/thermostat.rb).
(I am the author of RedShift. You can find my RubyConf 2009 presentation on
the confreaks site.)

------
vog
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.

~~~
kmanzana
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!

------
jfsantos
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](https://github.com/SciRuby/nmatrix)

------
blutack
FreeMAT is a really good OS clone of Matlab.

[http://freemat.sourceforge.net/](http://freemat.sourceforge.net/)

------
jurassic
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?

~~~
fnordfnordfnord
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"

~~~
kmanzana
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

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

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

------
jostmey
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.

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

~~~
kmanzana
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.

