Hey There,
Welcome to this first blog on Matlab in Linux series.
Well, as I wrote in the introduction that, I will be assuming basic familiarity with linux systems and bash shell particularly.
Welcome to this first blog on Matlab in Linux series.
Well, as I wrote in the introduction that, I will be assuming basic familiarity with linux systems and bash shell particularly.
If you have basic knowledge of matlab, that would be an added advantage here.
Goal of this series of blogs is to get people going on matlab linux version, which seems to be a popular choice amongst many image processing labs around the world and getting a display there may not be possible, all you have is a "terminal".
Besides this, there is one more important point that I want to you to understand here. World of machine language programs is too different from usual programs. These programs take hours, days in cases to finish. It makes it extremely important to make use of linux functionalities to cope up with these kind of problems.
So, getting back on track, I am assuming that you have some version of matlab installed on your machine. Hopefully (2008/2009). Use any linux distro doesnt matter really.
Check if you can start normal matlab by typing,
matlab on your terminal.
This should give you the old familiar matlab window on your desktop. We however are going to use command line version. Hence the command in our case would be
matlab -nojvm
This command should give you the matlab prompt. as follows
[omkar@localhost ~]$ matlab -nojvm
< M A T L A B >
Copyright 1984-2004 The MathWorks, Inc.
Version 7.0.0.19901 (R14)
May 06, 2004
Copyright 1984-2004 The MathWorks, Inc.
Version 7.0.0.19901 (R14)
May 06, 2004
To get started, type one of these: helpwin, helpdesk, or demo.
For product information, visit www.mathworks.com.
>>
This is that famous matlab prompt.
Now that we have prompt, The second most important thing to have is an editor.
I will be using vim editor. You can use any one of your choice.
So open another terminal window.
Go to the directory where you want your first program to be,
Open the edior and write the following line into it,
display('This is my first Matlab program');
display ('Halo World');
display ('Halo World');
Save the file as first.m As many of you might know, ".m" is a file extension of matlab
program files just like .c is for c programs.
Now go back to your terminal window where matlab is opened,
Make sure that you are working in the same directory where you stored your program.
You can check your current working directory by command pwd.
It will be the directory from where you have started matlab.
So in my case it looks like this.
>> pwd
ans =
/home/omkar
You can change the directory by command cd destination_path
Matlab should provide you with autocomplete with TAB key as you type the path, just as
your terminal does.
So once you are there the directory you created your program in,
check if your program is the there by ls '*.m' command.
>> ls '*.m'
first.m
Now everything is done, matlab has been started, we wrote our first matlab program,
we are there in the directory that we stored it in,
Only thing remaining now is to execute it,
So,
Just type the name of the file on the terminal, excluding the .m
>> first
This is my first Matlab program
Halo World
Thats it, we did it, the first of our matlab command line program. See.. The world here is not
That difficult as it may seem.
See you in my next blog then,where we will start looking at things in more details.
Do let me know your views about the blog.
~Omkar

No comments:
Post a Comment