Friday, March 29, 2013

Using m-functions in FreeMat

FreeMat is a free environment for rapid engineering and scientific prototyping and data processing. It is similar to commercial systems such as MATLAB from Mathworks.

If you don't have FreeMat installed, you can refer here how to get FreeMat.

The folder where you save the m functions should be defined in FreeMat path.

Step 1, Open pathtool in FreeMat:
The tool to integrate m-function folder in FreeMat is pathtool.

(a) Open FreeMat and type pathtool and Enter. Alternatively you can open the path tool window from the menu  Tool > Path Tool
(b) Find the folder where you save your m files (for example m-functions) on the left box, then select  Add, Save then confirm it by pressing Done.

Step 2, Restart FreeMat:
Restart FreeMat to completely integrate the m files path.

After restarting FreeMat, it can access and use the m files located in the folder (in this example the name of the folder is m-functions).

Sunday, March 17, 2013

Installation Fortran Java and C++ in Netbeans IDE

The following steps will guide you to install free GNU Fortran (gfortran), C/C++ (g++) and Java (oracle) in Netbeans in Windows7. There are 3 installation parts that you have to do, starting from Part 1, Part 2 then Part 3.

PART 1 - Install GNU Fortran (gfortran) and GNU C/C++ (g++)

Step 1 - Download gfortran and g++ from MinGW

MinGW, a contraction of "Minimalist GNU for Windows", is a minimalist development environment for native Microsoft Windows applications.

MinGW includes GNU Compiler Collection (GCC), including C, C++, ADA and Fortran compilers.

You have to download GUI wrapper (mingw-get-inst) for the command line installer. Select the latest one from here. For example mingw-get-inst-20120426.exe

Step 2 - Install MinGW to your computer

This step will install C, C++, Fortran, MSYS basic system, and MinGW developer tool.

Goto your folder where you saved MinGW installer, and just run it (or double click) to start the installation process. Do not change the default installation folder, so Netbeans path will recognise MinGW.

Make sure you select the required components (C, C++, Fortran, MSYS, and MinGW) when you are requested to select the components.

Step 3 - Add installation path MinGW to your computer

This step will add MinGW installation path to your computer. Netbeans will recognize this path during the activation of C/C++ and Fortran compiler.

To edit your PATH environment variable in Windows:

  • Right click on Computer > Properties
  • Click the Advanced system settings
  • Click the Environment Variable
  • Select Path and click Edit
  • Add (DO NOT REPLACE THE EXISTING VALUE) to the end of variable value, the following paths:

PART 2 - Install Java and Netbeans

Step 1 - Download bundles Java+Netbeans

The bundle of the latest version of  Java+Netbeans can be downloaded from Oracle website. Select JDK + Netbeans
Accept the agreement and start dowloading the bundle installer (-i586.exe for 32bit machine, -x64.exe for 64bit machine).

Step 2 - Install Java+Netbeans

This step will install Netbeans and Java.

As normal installation in Win7, goto the folder where you saved the executable bundle java+netbeans, then run it (or double click) the exe file. Follow all instructions until successfully completed.

Step 3 - Activate C/C++ and Fortran 

Your C/C++ and Fortran have not been activated. The C/C++ plugin must be installed. Although the name is plugin C/C++, it includes Fortran compiler as well. Open Netbeans, from the menu Tools, select Plugins
From the available plugin list, select C/C++. Then click the Install button. This plugin will be downloaded from Netbeans repository.

Step 4 - Setting C/C++ and Fortran paths

Open Netbeans, from the menu Tools, select Options
Select C/C++ tab, then click  Restore Defaults
If the paths cannot be automatically appeared, make sure you do PART-1 Step-3.

PART 3 - Testing your installation works

Step 1 - Fortran Hello Word test

Now you can test your Fortran. 

  • Open Netbeans
  • File > New Project > Select Project >Choose Project - Samples -  C/C++ > Fortran Hello Word Application
         Continue until finish setting the new project.
  • From the project window, select bar.f then Run. You should be able to run your fortran program.
Step 2 - C++ Welcome test

Now you can test your C++. 

  • Open Netbeans
  • File > New Project > Select Project > Choose Project - Samples -  C/C++  > Welcome
  • Continue until finish setting the new project.

  • From the project window, select then Run. You should be able to run your C++ program.

Now you have a powerful programming environment in your computer. You can use Fortran, Java or C/C++.