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

Monday, July 17, 2006

[Matlab] reshape

OUT = reshape(IN, [m n p ...] );
For input matrix IN, the data to be taken is of the following order:

IN[1,1,1,...];
IN[2,1,1,...];
IN[3,1,1,...];
...
IN[1,2,1,...];
IN[2,2,1,...];
...

Similarly, the data to be assigned in output matrix OUT is of the following order:

OUT[1,1,1,...];
OUT[2,1,1,...];
OUT[3,1,1,...];
...
OUT[1,2,1,...];
OUT[2,2,1,...];
...

Monday, July 10, 2006

[CPP] Using const

Source:
Declaring a const variable
  • General Rule: The 'const' qualifier works on everything on the left of it.
  • Convention: If a type T is not a reference or a pointer, a constant variable of type T can be declared by putting 'const' in front of T
Passing reference-to-const v.s. passing pointer-to-const
Taking the pointer to a temporary is not allowed but it is possible to pass a temporary to a function as a reference-to-const:
void foobar(T const&);
foobar( T() ); // Allowed.
Constant/non-constant method and constant/non-constant returned value
class Foo
{
public:
/*
* Modifies m_widget and the user
* may modify the returned widget.
*/
Widget *widget();

/*
* Does not modify m_widget but the
* user may modify the returned widget.
*/
Widget *widget() const;

/*
* Modifies m_widget, but the user
* may not modify the returned widget.
*/
const Widget *cWidget();

/*
* Does not modify m_widget and the user
* may not modify the returned widget.
*/
const Widget *cWidget() const;

private:
Widget *m_widget;
}
  • Const method: A method that does not modify the member variables of a class. Calling non-constant methods within a const method is not allowed.

Friday, July 07, 2006

[FINANCE] Site Links

MarketingShift

San Diego Source | San Diego Daily Transcript

I saw some investing info from the columnist Brent Wilsey

楚狂人的Blog

(Trad. Chinese)

Thursday, July 06, 2006

[HTML] Special Characters

Source:

http://www.w3.org/MarkUp/html-spec/html-spec_13.html

REFERENCE DESCRIPTION
-------------- -----------
&#00; - &#08; Unused
&#09; Horizontal tab
&#10; Line feed
&#11; - &#12; Unused
&#13; Carriage Return
&#14; - &#31; Unused
&#32; Space
&#33; Exclamation mark
&#34; Quotation mark
&#35; Number sign
&#36; Dollar sign
&#37; Percent sign
&#38; Ampersand

&#39; Apostrophe
&#40; Left parenthesis
&#41; Right parenthesis
&#42; Asterisk
&#43; Plus sign
&#44; Comma
&#45; Hyphen
&#46; Period (fullstop)
&#47; Solidus (slash)
&#48; - &#57; Digits 0-9
&#58; Colon
&#59; Semi-colon
&#60; Less than
&#61; Equals sign
&#62; Greater than
&#63; Question mark

&#64; Commercial at
&#65; - &#90; Letters A-Z
&#91; Left square bracket
&#92; Reverse solidus (backslash)
&#93; Right square bracket
&#94; Caret
&#95; Horizontal bar (underscore)
&#96; Acute accent
&#97; - &#122; Letters a-z
&#123; Left curly brace
&#124; Vertical bar
&#125; Right curly brace
&#126; Tilde
&#127; - &#159; Unused

&#160; Non-breaking Space
&#161; Inverted exclamation
&#162; Cent sign
&#163; Pound sterling
&#164; General currency sign
&#165; Yen sign
&#166; Broken vertical bar
&#167; Section sign
&#168; Umlaut (dieresis)
&#169; Copyright
&#170; Feminine ordinal
&#171; Left angle quote, guillemotleft
&#172; Not sign
&#173; Soft hyphen
&#174; Registered trademark
&#175; Macron accent
&#176; Degree sign

&#177; Plus or minus
&#178; Superscript two
&#179; Superscript three
&#180; Acute accent
&#181; Micro sign
&#182; Paragraph sign
&#183; Middle dot
&#184; Cedilla
&#185; Superscript one
&#186; Masculine ordinal
&#187; Right angle quote, guillemotright
&#188; Fraction one-fourth
&#189; Fraction one-half
&#190; Fraction three-fourths
&#191; Inverted question mark
&#192; Capital A, grave accent
&#193; Capital A, acute accent

&#194; Capital A, circumflex accent
&#195; Capital A, tilde
&#196; Capital A, dieresis or umlaut mark
&#197; Capital A, ring
&#198; Capital AE dipthong (ligature)
&#199; Capital C, cedilla
&#200; Capital E, grave accent
&#201; Capital E, acute accent
&#202; Capital E, circumflex accent
&#203; Capital E, dieresis or umlaut mark
&#204; Capital I, grave accent
&#205; Capital I, acute accent
&#206; Capital I, circumflex accent
&#207; Capital I, dieresis or umlaut mark
&#208; Capital Eth, Icelandic
&#209; Capital N, tilde
&#210; Capital O, grave accent

&#211; Capital O, acute accent
&#212; Capital O, circumflex accent
&#213; Capital O, tilde
&#214; Capital O, dieresis or umlaut mark
&#215; Multiply sign
&#216; Capital O, slash
&#217; Capital U, grave accent
&#218; Capital U, acute accent
&#219; Capital U, circumflex accent
&#220; Capital U, dieresis or umlaut mark
&#221; Capital Y, acute accent
&#222; Capital THORN, Icelandic
&#223; Small sharp s, German (sz ligature)
&#224; Small a, grave accent
&#225; Small a, acute accent
&#226; Small a, circumflex accent
&#227; Small a, tilde

&#228; Small a, dieresis or umlaut mark
&#229; Small a, ring
&#230; Small ae dipthong (ligature)
&#231; Small c, cedilla
&#232; Small e, grave accent
&#233; Small e, acute accent
&#234; Small e, circumflex accent
&#235; Small e, dieresis or umlaut mark
&#236; Small i, grave accent
&#237; Small i, acute accent
&#238; Small i, circumflex accent
&#239; Small i, dieresis or umlaut mark
&#240; Small eth, Icelandic
&#241; Small n, tilde
&#242; Small o, grave accent
&#243; Small o, acute accent
&#244; Small o, circumflex accent

&#245; Small o, tilde
&#246; Small o, dieresis or umlaut mark
&#247; Division sign
&#248; Small o, slash
&#249; Small u, grave accent
&#250; Small u, acute accent
&#251; Small u, circumflex accent
&#252; Small u, dieresis or umlaut mark
&#253; Small y, acute accent
&#254; Small thorn, Icelandic
&#255; Small y, dieresis or umlaut mark

[SOFTWARE] List of my favorites

ExamDiff

http://www.prestosoft.com/ps.asp?page=edp_examdiff
A freeware to compare text or binary files.

PSPad

A free text editor for various programming languages. Download

VirtuaWin

Virtual Desktops for Windows

Personal Brain

A thought mapping tool. Download