How to display and delete different line in graph when checkbox check and uncheck
3 views (last 30 days)
Show older comments
Hey there, I need to make a application in which i need to display graph for sensor reading, I am reading temerature sensor light sensor accelerator sensor. and these option is in check box, firstly when i click connect button the temperature sensor should be in graph only then when i click checkbox the line should appear in graph, when i uncheck it line should disappear, and all the line should be in single graph.
I am posting my code which is only dummy but data is live from arduino.
clear all; global a; % global p1; % global p2;
tempflag =0; global secondflag; secondflag = 0; iter =1; a = arduino('COM7', 'Uno');
% --- Executes on button press in pushbutton1. function pushbutton1_Callback(hObject, eventdata, handles) set(handles.axes1, 'Visible','on'); % %
x=0; global a; global tempflag;
while 1 % disp(tempflag);
v=readVoltage(a,'A0');
analog = (v/0.0048875);
temp = -(analog * 0.48828125);
%disp(temp);
x = [x temp];
handles.p1 = plot(handles.axes1 , x, 'color', 'blue');
set(handles.p1, 'tag', 'p1');
subplot(2, 2, [1 3]);
% hold on;
% handles.p2 = plot (handles.axes1, -x , 'color', 'red');
% set(handles.p2, 'tag', 'p2');
legend('Temperature','Location', 'southwest');
xlabel('Time') % x-axis label
ylabel('Temerature') % y-axis label
grid;
set(handles.edit1,'String', num2str(temp));
pause(0.5);
end
if(value == 0) % delete(findobj('tag','p1')); set(findobj('tag','p1'), 'Visible', 'off') ; hold on; % tempflag =1;
iter = 0; elseif (value == 1) % set(findobj('tag','p1'), 'Visible', 'on') ; % tempflag =0; %show again
end
please help me on this
0 Comments
Answers (1)
Massimo Zanetti
on 10 Feb 2017
Yuo may find it useful reading these tutorials https://it.mathworks.com/help/matlab/creating_guis/about-the-simple-guide-gui-example.html
See Also
Categories
Find more on Develop Apps Using App Designer 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!