Inserting value to a database not working...

1 view (last 30 days)
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?

Accepted Answer

Walter Roberson
Walter Roberson on 3 Apr 2013
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 Comment
Sayak
Sayak on 3 Apr 2013
ohhhh, yes yes. My database attribute datatype is character. So is the problem. Thanks. :-)

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!