Monday, August 28, 2006

[Tools] Site Links

Equation Sheet
A website containing many frequently used equations including following fields:
Algebra
Calculus
Chemistry
Geometry
Physics
Signal Processing
Statistics
Trigonometry

Thursday, August 24, 2006

[Matlab][CPP] Execute Command Line Commands

[Matlab] Execute Command Line Commands

Source

Matlab Helps

Syntax:

[status, result] = system('command')
[CPP] Execute Command Line Commands

Source

Microsoft MSDN

Syntax:

int result = system( const char *command );

Codes:

char cmd[200];
sprintf( cmd, "copy output.txt output_%d_%d_%d.txt", i, j, k);
system( cmd );

[Matlab] Figure Commands

Save Figure

Source:

http://www.mathworks.com/access/helpdesk/help/techdoc/ref/saveas.html
http://www.mathworks.com/access/helpdesk/help/techdoc/ref/print.html

Syntax:

Method 1:

saveas(h,'filename.ext')
saveas(h,'filename','format')

Method 2: (Using print function which allows user-defined print size)

set(h, 'PaperPositionMode', 'auto' );
set(h, 'PaperUnits', 'points');
set(h, 'PaperSize', [width height] );
print -dformat -rresolution filename;

Example:

Method 1:

h = figure;
plot(sin(0:0.1/2*pi:2*pi));
saveas(h, 'd:\temp\test.jpg'); %Automatically save it as a jpeg file
saveas(h, 'd:\temp\test.dat', 'fig'); % Force matlab to save it as a fig file

Method 2:

h = figure('Position', [1 100 900 500] );
plot(sin(0:0.1/2*pi:2*pi));

% Set 'PaperPositionMode' to 'auto' so that the print function will not resize the figure
set(h, 'PaperPositionMode', 'auto' );
% Set 'PaperUnits' to 'points' so that the the paper size can be defined in points.
set(h, 'PaperUnits', 'points');
% Set 'PaperSize' to the desired size in points. For some reason the value of width and height will be 4/3 times in pixels in the output file when printing the file at screen resolution (using -r0).
set(h, 'PaperSize', [900 500]*3/4 );
% use '-djpeg' to print the file in jpeg format. Use -r0 to specify the print resolution equal to screen resolution.
print -djpeg -r0 'test.jpg'

Support formats:

ai: Adobe Illustrator `88
bmp: Windows bitmap
emf: Enhanced metafile
eps: EPS Level 1
fig: MATLAB figure (invalid for Simulink models)
jpg: JPEG image (invalid for Simulink models)
m: MATLAB M-file (invalid for Simulink models)
pbm: Portable bitmap
pcx: Paintbrush 24-bit
pgm: Portable Graymap
png: Portable Network Graphic
sppm: Portable Pixmap
tif: TIFF image, compressed

Adjust the plot range

Source:

http://www.mathworks.com/access/helpdesk/help/techdoc/ref/index.html?/access/helpdesk/help/techdoc/ref/xlim.html

Syntax

xlim([xmin xmax]);

[Matlab] Startup Options

Source:

Matlab Help: Startup Options

Options:

/c licensefile
Set LM_LICENSE_FILE to licensefile.
/logfile logfilename
Automatically write output from MATLAB to the specified log file.
/minimize
Start MATLAB with the desktop minimized.
/nosplash
Start MATLAB without displaying the MATLAB splash screen.
/r MATLAB_file
Automatically run the specified MATLAB M-file, either commands supplied with MATLAB or your own M-files, immediately after MATLAB starts.


for options use '/' in Windows; use '-' in UNIX.

Example:

matlab /r myroutine.m % Call a script
matlab -r "plot( sin([1:10]) )" % Call a function with argument

NOTES:

matlab won't automatically close after running the script/function. Better to put "exit;" at the end of the script or after the funtion like
matlab -r "plot( sin([1:10]) ); exit;"

Tuesday, August 22, 2006

[Perl] Site Links

Forums
http://forums.devshed.com/perl-programming-6/
Sites
Perl Beginners First Response A website that provides many FAQ search results (Not sure if there are resources other than search results). I have difficulty using the search engine in this website, but an alternative is to google my question with keyword "Perl Beginners First Response"

Monday, August 21, 2006

[Perl] Basic Hash operations

Source:

Perl Howto --> Hash by Alex BATKO <abatko AT cs.mcgill.ca>

Codes:

my %hash = ();
%hash = ( 'key1', 'value1', 'key2', 'value2', 'key3', 'value3');
%hash = ( 'key1' => 'value1',
'key2' => 'value2',
'key3' => 'value3' );
$hash{ $key } = $value;
my %hash_copy = %hash;

if exists $hash{ $key };
if defined $hash{ $key };
if $hash{ $key };

delete $hash{$key}

# size of a hash
my $hash_size = keys( %hash );

# Process each key of the hash
while ( my ($key, $value) = each(%hash) ) { print "$key => $value\n"; }
for my $key ( keys %hash )
{
my $value = $hash{$key}; print "$key => $value\n";
}

For Hash references:

my $hash_ref = 0;
$hash_ref->{ $key } = $value; # $hash_ref is a reference of a hash.
delete $hash_ref->{$key};

# size of a hash
my $hash_ref_copy = $hash_ref;
my $hash_ref_size = 0; $hash_ref_size += scalar keys %$hash_ref;

# Process each key of the hash
while ( my ($key, $value) = each(%$hash_ref) ) { print "$key => $value\n"; }

[Life] Site Links

http://www.flightstats.com/

A website to check the U.S. Flight status.

How Far Is It?

A website calculating how far two locations (on earth? Not sure about the universe) are.

Friday, August 11, 2006

[ENGL] Site Links

WordReference Forums

A forum discussing words and idioms.

Englishforums.com

A forum for learning English / Letter writing / Gramma