problem saving files from 4 axes into a folder
3 views (last 30 days)
Show older comments
hello, i have codes for saving files from axes to a folder named Citra Latih and also the path of the folder will be saved into mysql. but there is an error, it says:
Error in inputcitra>buttonsimpan_Callback (line 352)
imwrite(Image1,baseFileName1,'bmp','WriteMode','append');
here is the codes:
function buttonsimpan_Callback(hObject, eventdata, handles)
S=get(handles.txtnama,'String');
if isempty(S)
msgbox('Harap isi Nama terlebih dahulu','PERINGATAN','warn');
else
S = get(handles.edit1, 'string');
file = char(S);
W = get(handles.txtnama, 'String');
save('file','W');
tanggal=get(handles.txttanggal,'String');
Frame1 =getframe(handles.axes1);
Image1 = frame2im(Frame1);
Frame2 =getframe(handles.axes2);
Image2 = frame2im(Frame2);
Frame3 =getframe(handles.axes3);
Image3 = frame2im(Frame3);
Frame4 =getframe(handles.axes4);
Image4 = frame2im(Frame4);
folder = 'F:\Skripsi\Citra Latih';
filepattern=fullfile(folder, '*.bmp');
files=dir(filepattern);
numberoffiles=length(files);
baseFileName1 = char(['F:\Skripsi\Citra Latih\',num2str(numberoffiles+1),'.bmp']);
imwrite(Image1,baseFileName1,'bmp','WriteMode','append');
baseFileName2 = char(['F:\Skripsi\Citra Latih\',num2str(numberoffiles+2),'.bmp']);
imwrite(Image2,baseFileName2,'bmp','WriteMode','append')
baseFileName3 = char(['F:\Skripsi\Citra Latih\',num2str(numberoffiles+3),'.bmp']);
imwrite(Image3,baseFileName3,'bmp','WriteMode','append')
baseFileName4 = char(['F:\Skripsi\Citra Latih\',num2str(numberoffiles+4),'.bmp']);
imwrite(Image4,baseFileName4,'bmp','WriteMode','append')
conn=database('database','root','','com.mysql.jdbc.Driver','jdbc:mysql://localhost:3306/');
id1 = str2num(get(handles.txtid, 'String'));
id2=id1+1;
id3=id2+1;
id4=id3+1;
gabung=get(handles.txtnama, 'String');
nama1 = ([gabung,'-LATIH-A']);
nama2 = ([gabung,'-LATIH-B']);
nama3 = ([gabung,'-LATIH-C']);
nama4 = ([gabung,'-LATIH-D']);
alamat1 = baseFileName1;
alamat2 = baseFileName2;
alamat3 = baseFileName3;
alamat4 = baseFileName4;
%foto = get(handles.txtlokasi, 'String');
tanggal = get(handles.txttanggal, 'String');
datainsert(conn,'irismata',{'ID','Nama','Lokasi','Tanggal'},{id1, nama1, alamat1, tanggal});
datainsert(conn,'irismata',{'ID','Nama','Lokasi','Tanggal'},{id2, nama2, alamat2, tanggal});
datainsert(conn,'irismata',{'ID','Nama','Lokasi','Tanggal'},{id3, nama3, alamat3, tanggal});
datainsert(conn,'irismata',{'ID','Nama','Lokasi','Tanggal'},{id4, nama4, alamat4, tanggal});
close(conn);
msgbox('Citra Latih berhasil disimpan','BERHASIL','warn');
set(handles.buttontemplate,'Enable','off');
set(handles.buttonnormal,'Enable','off');
set(handles.buttondeteksi,'Enable','off');
set(handles.buttonpilih,'Enable','on');
set(handles.txttanggal,'String',(datestr(date, 'yyyy-mm-dd')));
cla(handles.axes1);
cla(handles.axes2);
cla(handles.axes3);
cla(handles.axes4);
conn=database('database','root','','com.mysql.jdbc.Driver','jdbc:mysql://localhost:3306/');
setdbprefs('NullNumberWrite', 'NaN');
SQL=['select max(id) from irismata'];
curs = exec(conn,SQL);
curs = fetch(curs);
mydata=curs.Data;
a = cell2mat(mydata);
for ii = (a(1)+0):(a(1)+1)
fn = (num2str(ii,'%i'));
set(handles.txtid, 'String', fn);
end
end
0 Comments
Accepted Answer
Walter Roberson
on 3 Jun 2017
Edited: Walter Roberson
on 3 Jun 2017
It would be cleaner to use
baseFileName1 = fullfile(folder, [num2str(numberoffiles+1),'.bmp'] );
However, you real problem is that 'WriteMode', 'append' is supported only for: GIF, HDF4, and TIFF. You cannot append to BMP.
17 Comments
Walter Roberson
on 6 Jun 2017
Change
tmp_name = tempname(folder);
to
tmp_name = fullfile(folder, get(handles.txtnama, 'string') );
More Answers (0)
See Also
Categories
Find more on Convert Image Type in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!