有用的Matlab 内置函数

Mod – modulus after division
减法之后取模
e.g.

for i = 1:100
if(mod(i,20)==0), fprintf(1,'%i..',i); end;
end;

得到100之内20的倍数
 

fprintf – Write data to text file 
Syntax

fprintf(fileID, format, A, ...)
fprintf(format, A, ...)
count = fprintf(...)

参数:
fileID
One of the following: An integer file identifier obtained from fopen.
1 for standard output (the screen).
2 for standard error.
Default: 1 (the screen)

format
String in single quotation marks that describes the format of the output fields. Can include combinations of the following:
Percent sign followed by a conversion character, such as ‘%s’ for strings.
Operators that describe field width, precision, and other options.
Literal text to print.
Escape characters, including:
” Single quotation mark
%% Percent character
\\ Backslash
\a Alarm
\b Backspace
\f Form feed
\n New line
\r Carriage return
\t Horizontal tab
\v Vertical tab
\xN Hexadecimal number, N
\N Octal number, N

另一个formatted输出的函数是sprintf – Format data into string
Syntax

str = sprintf(format, A, ...)
[str, errmsg] = sprintf(format, A, ...)

Description
str = sprintf(format, A, …) applies the format to all elements of array A and any additional array arguments in column order, and returns the results to string str.
[str, errmsg] = sprintf(format, A, …) returns an error message string when the operation is unsuccessful. Otherwise, errmsg is empty.

dir – List folder contents
Syntax

dir
dir name
listing = dir(name)

Description
dir lists the files and folders in the MATLAB current folder. Results appear in the order returned by the operating system.
dir name lists the files and folders that match the string name. When name is a folder, dir lists the contents of the folder. Specify name using absolute or relative path names. You can use wildcards (*).
listing = dir(name) returns attributes about name.

r = dir('my_dir')
r(n) = 
  name: 'my_file'
  date: ''
  bytes: []
  isdir: 0
  datenum: []
where n is the index for my_file

例如:

>> files = dir([det_dir 'det+pos/*.mat'])
files = 
288x1 struct array with fields:
    name
    date
    bytes
    isdir
    datenum
>> files(1)
ans = 
       name: 'crop001501.mat'
       date: '17-Jun-2009 01:19:06'
      bytes: 277
      isdir: 0
    datenum: 7.3394e+005

clf – Clear current figure window

randperm – Random permutation 1:n范围内的可能排列
Syntax

p = randperm(n)

Description
p = randperm(n) returns a random permutation of the integers 1:n.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

生活在西班牙

自己动手丰衣足食

BlueAsteroid

Just another WordPress.com site

Jing's Blog

Just another WordPress.com site

Start from here......

我的心情魔方

天才遠私廚

希望能做一個分享各種資訊的好地方

语义噪声

西瓜大丸子汤的博客

笑对人生,傲立寰宇

Just another WordPress.com site

Where On Earth Is Waldo?

A Project By Melanie Coles

the Serious Computer Vision Blog

A blog about computer vision and serious stuff

Cauthy's Blog

paper review...

Cornell Computer Vision Seminar Blog

Blog for CS 7670 - Special Topics in Computer Vision

datarazzi

Life through nerd-colored glasses

Luciana Haill

Brainwaves Augmenting Consciousness

槑烎

1,2,∞

Dr Paul Tennent

and the university of nottingham

turn off the lights, please

A bunch of random, thinned and stateless thoughts around the Web

%d bloggers like this: