Inserting value to a database not working...

조회 수: 14 (최근 30일)
Sayak
Sayak 2013년 4월 3일
I have the following code which works perfectly but for the 'pix' field.
My code is:
mydir = 'E:\matlab\pet_dog\';
fid=fopen('E:\matlab\ratio for pet_dog.txt','wt');
allentries = dir(mydir);
diridxs = [allentries.isdir];
alldirs = allentries(diridxs);
allfiles = allentries(~diridxs);
for ctr = 1:length(allfiles)
x = fullfile(mydir, allfiles(ctr).name);
pix = double(nnz(edge(rgb2gray(imread(x)))));
%disp(pix);
ratio = fix(9600/pix);
logintimeout(5);
con = database('fetchDB', '', '');
ping(con);
exdata = {'9600',pix,'-',ratio,x};
colnames = {'imgSize', 'imgPixel', ' imgPart','ratio','imgName'};
fastinsert(con, 'animal', colnames, exdata)
close(con);
end
Why the field 'imgPixel' is not showing the numerical values properly? What should I do?

채택된 답변

Walter Roberson
Walter Roberson 2013년 4월 3일
Seems to me that is going to depend upon the schema you defined for the imgPixel column in the "animal" database. If it was previously defined as character, then it would stay as character until you changed the schema or deleted the database.
  댓글 수: 1
Sayak
Sayak 2013년 4월 3일
ohhhh, yes yes. My database attribute datatype is character. So is the problem. Thanks. :-)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Database Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by