![]() |
School of Computer Science
|
Note that you will not be able to unmount the floppy if you have a terminal window running with /mnt/floppy as the current directory - you will get an error message saying something like cannot unmount, device is currently active.
It is surprising that there is no convenient fine control of output format in MATLAB. Here is a function matprint.m that allows you to print out values to a desired number of decimal places using C style formatting commands.
>> h = text(0.5, 0.5, 'hello'); % Print 'hello' at position [0.5 0.5]Now get the attributes of the graphics object
>> get(h)
Color = [0 0 0]
EraseMode = normal
Editing = off
Extent = [0.496222 0.474522 0.0579345 0.0477707]
FontAngle = normal
FontName = Helvetica
FontSize = [10]
FontUnits = points
FontWeight = normal
HorizontalAlignment = left
Position = [0.5 0.5 0]
Rotation = [0]
String = hello
Units = data
Interpreter = tex
VerticalAlignment = middle
... + other stuff
>>
You can then change any of these attributes using the set function specifying
the attribute name (as a string) followed by the new attribute value. To change the text
written above to a red colour and font size of 16 we would use the following command
>> set(h,'Color',[1 0 0],'FontSize',16);More conveniently you can do the drawing and setting of attributes in the one command, here are some examples
>> text(0.5, 0.5, 'hello','Color',[1 0 0],'FontSize',16); line([0 1],[0 1]) >> line([0 1],[0 1],'LineWidth',2)Do a 'help' on get and set for more information
[x1 y1], [x2 y2], [x3 y3]you would use the command
>> line([x1 x2 x3], [y1 y2 y3])Note how you have to separate out the x and y coordinates into separate arrays.
Both line and plot draw into the current figure window. By default this will be the last figure that you used. You can specify a specific figure window using the figure command, for example
>> figure(3) % Make figure(3) 'active'. >> line([x1 x2 x3], [y1 y2 y3]) % Draw a line in figure 3.
The plot command clears the figure before drawing, the line command does not. You can prevent plot from clearing a figure using the command
>> hold on
Look at the code in circularstruct.m. This function is for generating circular structuring elements for morphological operations.
You can define a system variable called 'MATLABPATH' which is a list of directory (folder) names, separated by colons, in which MATLAB will always search to find your MATLAB function files.
For example if you have MATLAB '.m' files in subdirectories IT412 and IT412/lab2 you would edit your '.zshrc' file (found in your home directory) and append a line as follows:
export MATLABPATH=$HOME/IT412:$HOME/IT412/lab2(HOME is a predefined system variable that specifies your home directory)
You will need to log out and log in again, or run the command
% source .zshrcwithin the terminal window that you want to use MATLAB for your definition of MATLABPATH to take effect. Now you will be able to run your MATLAB functions from any directory
To avoid the GUI interface invoke MATLAB as follows:
% matlab -nojvm (do not run it in background ie don't use an & at the end)This starts MATLAB up without the Java Virtual Machine interface. MATLAB will start up very quickly and just give you a command window. You will find its response much, much more 'snappy'.
To create and edit command files you will have to use a separate text editor such as emacs, vi, vim or pico.
Download the following two files to your top home directory
If you use emacs to edit your files, and hence have no need for MATLAB's editor, invoke MATLAB as follows:
% matlab -nojvm (do not run it in background ie don't use an & at the end)This starts MATLAB up without the Java Virtual Machine interface. MATLAB will start up very quickly and just give you a command window. You will find its response much, much more 'snappy'.
I suggest that you set up sybolic links from your area to the image directories. This will give you direct access to any new images that are placed in these directories and save having multiple copies of images all over the place. The commands
prompt% ln -s /cslinux/examples/it412/Images Images
prompt% ln -s /cslinux/examples/it412/ClassOf2002 ClassOf2002
will create two symbolic links Images and
ClassOf2002 in your area that will take you directly to these
directories.