clear all;
close all;
clc;
onion   = rgb2gray(imread('onion.png'));
peppers = rgb2gray(imread('peppers.png'));
tic; % start for time
c = normxcorr2(onion,peppers);
[ypeak, xpeak] = find(c==max(c(:)));
yoffSet = ypeak-size(onion,1);
xoffSet = xpeak-size(onion,2);
toc; % stop for time




程序执行完毕之后,命令窗口输出一下内容:


MATLAB中统计程序执行时间_统计