matlab mark

################################矩阵缩维#######################################################
shiftdim(mat):矩阵缩维
###############################################################################################
-----------------------------------------------------------------------------------------------
################################读txt姿势(1)#######################################################
[a,b,c,d] = testread('file.txt','%d%d%d%d',n):{
    a = (n,1)
    b = (n,1)
    c = (n,1)
    d = (n,1)
    且 [a(1,1);b(1,1);c(1,1);d(1,1);a(2,1);b(2,1);c(2,1);d(2,1);...]'是file.txt的前4*n个元素.
}
###############################################################################################
-----------------------------------------------------------------------------------------------
################################读txt姿势(2)#######################################################
file = fopen('path/to/file','r');
while ~feof(file)
    tline = fgetl(file);
    tline = regexp(tline, ' ', 'split');
end
###############################################################################################
-----------------------------------------------------------------------------------------------
################################读txt姿势(3)#######################################################
file = fopen('file.txt');
C = textscan(file, '%s%d');
###############################################################################################
-----------------------------------------------------------------------------------------------
################################矩阵操作汇集#######################################################
1.sum(C,axis):压扁第axis,求和
2.M*M 对应位置相乘
3.C = repmat(C,[size1,size2])????
###############################################################################################
-----------------------------------------------------------------------------------------------
################################矩阵操作汇集#######################################################
fp = fopen('path\to\file','wt');
fprintf(fp, '%d', a(i));
fclose(fp);
###############################################################################################
-----------------------------------------------------------------------------------------------

posted on 2016-12-13 12:01  mathfinder  阅读(513)  评论(0编辑  收藏  举报

导航