0

i'm new to MATLAB. i have this code that extract image feature using gui. i have problem creating a code that can record data extracted into csv and txt file. i want the data extracted from the image to be record into a single csv file each time an image is load into the gui. the data will be use to train a neural network. can some one help me? tq

   %~~~~~~~~~~~~~~~~~~~~~~~~use when train data~~~~~~~~~~~~~~~~~~~~~
   % stt=0; %use it when train data\\set grade value set 1 if pet, set 0 if nonpet
   % humoment=[num2str(M1) ',' num2str(M2) ',' num2str(M3) ',' num2str(M4) ',' num2str(M5) ',' num2str(M6) ',' num2str(M7) ',' num2str(perimeter) ',' num2str(area) ',' num2str(xbar) ',' num2str(ybar) ',' num2str(stt)];
   % Record (humoment,'C:\MATLABDATA\datatrain.csv') %use it when train data
   % %~~~~~~~~~~~~~~~~~~~~~~~~use when test data~~~~~~~~~~~~~~~~~~~~~~
   humoment=[num2str(M1) ',' num2str(M2) ',' num2str(M3) ',' num2str(M4) ',' num2str(M5) ',' num2str(M6) ',' num2str(M7) ',' num2str(perimeter) ',' num2str(area) ',' num2str(xbar) ',' num2str(ybar) ];

    data= [filename ',' num2str(M1) ',' num2str(M2) ',' num2str(M3) ',' num2str(M4) ',' num2str(M5) ',' num2str(perimeter) ',' num2str(M6) ',' num2str(M7) ',' num2str(area) ',' num2str(xbar) ',' num2str(ybar)];
   Record(humoment,'C:\MATLABDATA\datatest.csv')
   Record(data,'C:\MATLABDATA\datatest.txt')  
   set(handles.edit45,'String','Load completed')

   end

1 Answer 1

2

The simplest solution might be to replace

   Record(humoment,'C:\MATLABDATA\datatest.csv')
   Record(data,'C:\MATLABDATA\datatest.txt')

with

fid = fopen('C:\MATLABDATA\datatest.csv','a+');
fprintf(fid,[humoment,'\n']);
fclose(fid);

fid = fopen('C:\MATLABDATA\datatest.txt','a+');
fprintf(fid,[data,'\r\n']);
fclose(fid);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.