利用matlab将数据写入指定列的方法

最近忙着毕业设计,主要是提取TID2008图库里的图像的特征,然后用于分类器。其中用到matlab程序,提取特征存成excel的,第一列是图片名字,第二列往后 是提取出来的特征。

其中图片格式是bmp的

程序很简单:

clc
clear all
close

pathname = uigetdir(cd, '请选择文件夹');
if pathname == 0
    msgbox('您没有正确选择文件夹');
    return;
end


filesname = ls(strcat(pathname,'/*.bmp'));%strcat连接字符串
files = [cellstr(filesname)]; % 得到文件路径

len = length(files); % 文件个数
for i=1:len;
 image = imread(strcat(pathname,'\',files{i}));

 I=rgb2gray(image);
 imagefeature = feature_extract(double(I));
 datas(i,:) = imagefeature;
end
%dlmwrite('featureblur.data',datas,'delimiter', ',','newline','pc');
xlswrite('featureblur.xls',datas,'sheet1','B1');%将特征写入sheet1,从第二列(B1)开始
xlswrite('featureblur.xls',files,'sheet1','A1');%将特征写入sheet1,从第一列(A1)开始
原文地址:https://www.cnblogs.com/mothe123/p/3052105.html