Article Directory
String processing
int2str
Convert integer to string
a=int2str(k)
str2int
Convert string to integer
k=str2int(a)
strcat
Concatenate several strings together
a=strcat('hello',' ','world');
Matrix processing
size
Get the number of rows and columns of the matrix
[row,col]=size(a);
s=size(a,1); % 返回矩阵行数
s=size(a,2); % 返回矩阵列数
length
Count the number of elements in a one-dimensional array
s=length(a);
intersect
Calculate the same elements of two arrays (if an element appears repeatedly, it will only be counted once)
c=intersect(a,b);
find
Find the eligible element in the array or matrix and return its index value. (If it is a matrix, return the index value of the column storage code)
% 找到不为0的元素
>> X = [1 0 4 -3 0 0 0 8 6];
>> ind = find(X)
ind =
1 3 4 8 9
% 找到满足条件的元素
>> X = [1 0 4 -3 0 0 0 8 6];
>> ind = find(X == 4)
ind =
3
% 判断是否存在某元素
>> if isempty(find(X == 9))
log = 0
else
log = 1
end
log =
0
data processing
sum
% 对该列所有元素求和
sum(a(:,col));
mean
m=mean(A);
% 若A是向量则返回A中值的平均值,若是矩阵则返回每一列的平均值
mad
Median number
m=mad(A);
std
Find the standard deviation.
s=std(A);