matrix - Matlab: Can't handle data -


i writing program in matlab reads in matrix coming sensor (microcontroller arduino leonardo). can choose how fast matrices being recorded (e.g. 60 frames per min 1 matrix every second).

all works great, had create default file records matrices not recorded (let’s it’s fast enough record 8 matrices per sec , want 1 per sec, default file record other seven). otherwise i’d kicked out of here:

%get data %data read string (csv) data = str2double(strsplit(fgetl(serialport), ','));  if and(get(hobject,'value') == 1, correctport == 1)     %try right ports     try         %reshape data (1d -> 2d array) , display in matrix         k = 1;         = 1:nrow             j = 1:ncol                 % reading in tag names                 tagnames{k} = ['tag_matrix_' num2str(k)];                 % creating matrix                 data2d(row_index(i), col_index(j)) = data(k);                 % display in matrix                 set(handles.(tagnames{k}),'string',data2d(i,j));                 set(handles.(tagnames{k}),'visible','on');                 k = k + 1;             end         end     catch         set(handles.tag_txt3,'string','this not correct port. please correct port in device manager. set right port , start again');         set(handles.tag_onoff,'value',0);         set(handles.tag_log,'value',0);         set(handles.tag_log,'enable','off')         correctport = 0;     end end 

it goes through loop couple of time (a different number of times every time) i’ll send “catch”. happens if started recording or not. doesn't matter.

if have display matrices in command window (data2d(row_index(i), col_index(j)) = data(k) without ;) works.

here how record data:

% open writing % preparation if and(startlog == 1, correctport == 1)     set(handles.tag_txt3,'string','program running , recording data'); end % set interval = rectime after logging (don't worry that) if and(startlog == 1, counter == 0)     interval = rectime;     counter = 1; end % making sure have restart after stop logging if and(startlog == 0, counter == 1)     set(handles.tag_onoff,'value',0) end % record data when time has come if and(startlog == 1,time > interval)     fprintf(fid, '#');     fprintf(fid, '%u', matrixnumber);     fprintf(fid, '\n');     i=1:size(data2d,1)         fprintf(fid, '%g\t', data2d(i,:));         fprintf(fid,'\n');     end     interval = rectime + interval;     matrixnumber = matrixnumber + 1;     %making sure have choosen unit , send out error elseif and(startlog == 1,rectime == 0)     set(handles.tag_txt3,'string','choose unit , start again');     set(handles.tag_onoff,'value',0)     set(handles.tag_log,'value',0)     counter = 0; else     %this default file recording other matrices end 

hope can me. didn't wanna put in entire code because it's ten pages. please let me know if have further questions.

thank in advance

mike


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -