FreeMat—Yet Another MATLAB Replacement

Many programs exist that try to serve as a replacement for MATLAB. They all differ in their capabilities—some extending beyond what is available in MATLAB, and others giving subsets of functions that focus on some problem area. In this article, let's look at another available option: FreeMat.

The main Web site for FreeMat is hosted on SourceForge. Installation for most Linux distributions should be as easy as using your friendly neighborhood package manager. FreeMat also is available as source code, as well as installation packages for Windows and Mac OS X. Once it's installed, you can go ahead and start it up. This brings up the main window with a working console that should be displaying the license information for FreeMat (Figure 1).

Figure 1. When you first start up FreeMat, you are given a fresh console.

As with most programs like FreeMat, you can do arithmetic right away. All of the arithmetic operations are overloaded to do "the right thing" automatically, based on the data types of the operands. The core data types include integers (8, 16 and 32 bits, both signed and unsigned), floating-point numbers (32 and 64 bits) and complex numbers (64 and 128 bits). Along with those, there is a core data structure, implemented as an N-dimensional array. The default value for N is 6, but is arbitrary. Also, FreeMat supports heterogeneous arrays, where different elements are actually different data types.

Commands in FreeMat are line-based. This means that a command is finished and executed when you press the Enter key. As soon as you do, the command is run, and the output is displayed immediately within your console. You should notice that results that are not saved to a variable are saved automatically to a temporary variable named "ans". You can use this temporary variable to access and reuse the results from previous commands. For example, if you want to find the volume of a cube of side length 3, you could so with:


--> 3 * 3
ans =
 9
--> ans * 3
ans =
 27   

Of course, a much faster way would be to do something like this:


--> 3 * 3 * 3
ans =
 27

Or, you could do this:


--> 3^3
ans =
 27

If you don't want to clutter up your console with the output from intermediate calculations, you can tell FreeMat to hide that output by adding a semicolon to the end of the line. So, instead of this:


--> sin(10)
ans =
   -0.5440

you would get this:


--> sin(10);
-->

______________________

Joey Bernard has a background in both physics and computer science. This serves him well in his day job as a computational research consultant at the University of New Brunswick. He also teaches computational physics and parallel programming.

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

FreeMat

Jony's picture

This is an excellent post. I learned a lot about what you talking about. Not sure if I agree with you completely though. http://therionsolutions.com/blog

The biggest percentage

sollen's picture

The biggest percentage increase this year was in maintenance costs, which grew by 11.26% to 4.97 cents per mile, on average 60W 12V LED SUV driving Light for sedan owners. Average costs in all categories are lower for smaller vehicles and higher for bigger ones.

MATLAB is unique...

mishainfotech's picture

I think MATLAB is the unique software and there is no better replacement to it till now. It incorporates the real tools for the digital image processing geeks.........

Webinar
One Click, Universal Protection: Implementing Centralized Security Policies on Linux Systems

As Linux continues to play an ever increasing role in corporate data centers and institutions, ensuring the integrity and protection of these systems must be a priority. With 60% of the world's websites and an increasing share of organization's mission-critical workloads running on Linux, failing to stop malware and other advanced threats on Linux can increasingly impact an organization's reputation and bottom line.

Learn More

Sponsored by Bit9

Webinar
Linux Backup and Recovery Webinar

Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.

In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.

Learn More

Sponsored by Storix