Tuesday, February 20, 2007

[HTML] Symbol Reference

Greek, mathematical, symbolic characters, and so on.
http://everything2.com/index.pl?node=HTML%20symbol%20reference

Wednesday, January 17, 2007

[Matlab] Data Clipping, saturation

% 'x > upperbound' evaluates to a logical index
x = array to be clipped;
x( x > upperbound ) = upperbound;
x( x < lowerbound ) = lowerbound;

Tuesday, January 02, 2007

Quotes

"There is only one thing more beautiful than one guitar - Two guitars" Frederic Chopin

Wednesday, November 15, 2006

[EE] Forum and Sites

DSP related:
http://www.dsprelated.com/

Monday, November 06, 2006

[Math] Statistics Online Resources

http://davidmlane.com/hyperstat/index.html

Friday, November 03, 2006

[HTML] Tags

Link:

Bare Bones Guide to HTML

Frequently Used Tags

4.0* Underline <U></U> (not widely implemented)

Monday, October 02, 2006

[Matlab][Cpp] Time Telling

[Matlab] Generate file name with time

Codes:

currTime = clock;
fname = sprintf('myfilename_%02d%02d%02d%02d.txt', currTime(2:5) );

[Matlab]Timer
Measure how many seconds were elapsed.

Source:

Matlab Help

Codes:

t1 = clock;
%%%%%%%%%%%%%%%%
% Run your scripts
%%%%%%%%%%%%%%%%
t2 = clock;
Elapsed = etime(t2,t1);

[CPP] Timer Code
Measure how many seconds were elapsed.

Source:

http://www.cplusplus.com/ref/ctime/time.html

Codes:

#include <time.h>
time_t stime, etime;
stime = time(NULL);
...<Codes to be timed.>...
etime = time(NULL);
printf("Time elapsed: %ld seconds\n", etime-stime);

[CPP] Wait function
Make the program wait for several seconds.

Source:

http://www.cplusplus.com/ref/ctime/clock.html

Codes:

#include <time.h>

int seconds = 10;
clock_t endwait;
endwait = clock () + seconds * CLOCKS_PER_SEC ;
while (clock() < endwait) {}

[CPP] Print time/date info
Print the current date and time

Source:

http://www.cplusplus.com/reference/clibrary/ctime/ctime.html

Codes:

#include <stdio.h>
#include <time.h>

int main ()
{
time_t rawtime;

time ( &rawtime );
printf ( "The current local time is: %s", ctime (&rawtime) );

return 0;
}

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

Monday, July 31, 2006

[Matlab]Functions

B = squeeze(A):

Remove the singleton dimension;
Remove the dimensions of size 1;
Remove the redundant dimensions.

B = repmat(A,[m n p...]):

Replicate and tile an array

B = sub2ind(size,sub1, sub2, ...);
B = ind2sub(size, index);

Convert subscripts to index or vice versus

profile on;
...
profile viewer;

Profile execution time for function

[ENGL] Old Chinese Saying

An artisan must first sharpen his tools if he is to do his work well.

Thursday, July 27, 2006

Tuesday, July 18, 2006