if isnan(x)
do...
end
矩阵
取某些行或某些列
>> m = [1 2 3;4 5 6; 7 8 9];
>> p = logical([1;0;1]);
>> m(p,:)
字符串
字符串比较
strcmp
>> versicolor_indices = strcmp('versicolor',species);
函数
将统计函数应用到矩阵数据上时,函数将每个单独的列视为变量,最后将应用到每个变量后的结果组成向量返回。
Create Array zeros(), ones(), rand(), or randn()
Permutation perms()
点积 dot() or sum(x.*y)
叉积 cross()
求模 norm()
相似度计算
sim_vi_vj = dot(vi,vj)/(norm(vi)*norm(vj))
textread()数据载入
Examples:
Sally Type1 12.34 45 Yes
Read each column into a variable
[names,types,x,y,answer] = textread('mydata.dat','%s%s%f%d%s');
科学记数法文本数据读入
>> fid = fopen('file.txt','rt');
>> t = fscanf(fid, '%e');
>> fclose(fid);
合并 union()
去重 unique()
清屏 clc
回收空间 clear ?
查看变量类型 whos
时间
tic
程序代码
toc
注释
方法一:
选定要注释的块,Ctrl+r;取消注释, Ctrl+t。
方法二:
%{
需要注释不执行的若干命令行
%}