zoukankan      html  css  js  c++  java
  • matlab实用命令

    实用命令

    打点测时

    在需要测量的开始部分标记: tic    
    在需要测量的结束部分标记: toc
    记录程序从tic到toc运行所花费的时间
    

    Image 翻转

    fliplr(x)  	//左右翻转
    flipud(x)	//上下翻转
    rot90(x)	//旋转九十度
    

    find non-zero elem index

    %tipycally method to find the non-zero elem index in 2D matrix.
    indices = find(matrix);         %find non-zero elem by rows, return rank.
    [I, J] = ind2sub(size(matrix), indices);    %convert rank to row and col index
    

    read multifile in certain directory

    %a typical method for reading data from multitxt and merge them together.
    datapath = ''% datapath = 'data/tennis/';
    filelist = dir([datapath '/*.jpg']);
    imagelist = {filelist.name};
    for i = 1:nImg
       ld = dlmread([datapath imagelist{i}(1:end-4) '.jpg.txt']);
       w_gt = [w_gt; ld'];
    end
    

    Write and read .txt file

    读写矩阵
    dlmwrite('xpreds_3d.txt',preds_3d);     //store preds_3d matrix, it can only store 2 demension matrix
    M = dlmread('inputdata/o-ldmk.txt');
    //if demension is more than 2 ,it will merge from second dimension
    读写文本
    fp = fopen(fileOut,'w');
    fprintf(fp,'%d %d',m,n);
    fclose(fp);
    dlmwrite(fileOut,data1,'-append','delimiter',' ','roffset',1,'coffset',0);   //以空格结尾
    

    save and load .mat

    save(‘xx.mat’, ‘varname’)则变量varname会被保存在当前目录下xx.mat文件。
    再要使用变量时只要用load(‘xx.mat’)变量会被读入。
    如果使用xx = load(‘xx.mat’)读入,则xx.xx为真正的存入变量。
    

    Repmat

    A = [1 2; 3 4];
    B = repmat(A, [2 3 2]);
    //以A为子模块,把B复制成2行3列元素为A的大矩阵,并且这样的矩阵有两份
    

    std2

    std2(matrix) = sqrt( 1/(size(matrix,1)*size(matrix,2)) * sum( (mean(matrix(:)) - matrix ))(:) );
    
  • 相关阅读:
    【转载】10个Web3D可视化精彩案例
    基于react的audio组件
    如何开发一款堪比APP的微信小程序(腾讯内部团队分享)
    CSS3 用border写 空心三角箭头 (两种写法)
    浅谈微信小程序对于创业者,意味着什么?
    左手Cookie“小甜饼”,右手Web Storage
    css3中user-select的用法详解
    个人感觉一些比较有用的特效例子
    纯css模拟电子钟
    蓝桥杯 ALGO-2:最大最小公倍数
  • 原文地址:https://www.cnblogs.com/fariver/p/6500881.html
Copyright © 2011-2022 走看看