GUI Folder Sampling based on toggle button

1 view (last 30 days)
Trevor
Trevor on 19 Jun 2013
Hi Everyone,
I'm working on a project where data is being saved to a folder at random times. My goal is fairly simple:
1) Sample this folder and recognize when new data has been saved to it 2) Read the data into matlab and analyse it 3) Delete the data from the intial folder and continue sampling.
Currently I have a toggle button which when selected initiates the process above and is stopped when the toggle button is unselected. Simplified code:
function tg_start_Callback(hObject, eventdata, handles)
status=get(handles.tg_start,'Value');
if status==1
while current.main.status==1
fld_srch=dir('C:\Data\');
if ~isempty(fld_srch)
load(['C:\Data\',fld_srch{1,1}.name]); %inputs
[outputs]=customfunction([inputs]);
end
pause(0.5)
end
end
I'm wondering if there is a better way to do this other than having the while loop continuously sampling in the toggle_start callback until the toggle is unselected and status goes back to zero. I have some concerns that there may be some interrupt problems if the customfunction is part way through its analysis when the user unselects the toggle.
I'm still relatively new to working with GUIs so I appreciate your input on this small issue before I move forward to bigger and better problems!
Cheers, Trevor

Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!