Matlab - Graphical user interface (GUI), plot with arduino data -
i have matlab program done real time plot acquire data ldr sensor arduino. want implement program in gui , i'm facing problems ploting. here part of program dont know how plot in gui mode.
(...) while(1) state = a.analogread(0); (...) axis tight drawnow; x = [x, state]; plot(x,'-*b'); grid on; end
the code must in openingfcn? should copy paste there? have change in ploting code? thank much!
a neverending while
loop in openingfcn
indefinitely lock gui. you're better off creating timer object , running 'continually' plotting code code in callback; example:
function myui_openingfcn(hobject, eventdata, handles, varargin) % create timer delay of 0.1 seconds handles.tmrplot = timer( ... 'executionmode', 'fixedrate', ... 'period', 0.1, ... 'timerfcn', @myplottingfunction); % store in ui data guidata(hobject, handles); % start it! start(handles.tmrplot); end function myplottingfunction(src, evt) % plotting plot(rand(10)); drawnow; end
with timer can also, example, start , stop execution in callback of button.