Display command window data in gui matlab
3 views (last 30 days)
Show older comments
Hello, Here is my code,
% --- Executes on button press in process.
function process_Callback(hObject, eventdata, handles)
% hObject handle to process (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
diary off;
warning ('off','all');
diary('preprocessDetails.txt');
set(handles.process, 'Enable', 'off');
diary on;
handles.d{1} = 'Select text files with image paths...';
guidata(hObject, handles);
set(handles.list, 'String', handles.d);
fid = fopen('preprocessDetails.txt');
handles.d{2} = 'Extracting images...';
guidata(hObject, handles);
run preprocess; %this file writes intermediate training data to command window
set(handles.list, 'String', handles.d);
indic = 3;
while 1
handles.tline = fgetl(fid);
guidata(hObject, handles);
handles.d{indic}=handles.tline;
guidata(hObject, handles);
if ~ischar(handles.tline)
break
end
indic = indic + 1;
end
diary off;
fclose(fid);
set(handles.list,'string',handles.d);
set(handles.list, 'Value', 1);
delete preprocessDetails.txt;
set(handles.process, 'Enable', 'On');
warning ('on','all');
I want to write the diary entries into the listbox simultaneously as the preprocess is getting executed. Is there a way to do it?
Thank You.
0 Comments
Accepted Answer
Jan
on 13 Apr 2014
No, this cannot work. The diary file is written in buffered mode, such that it is even not written simultaneously with the processing to the disk. Therefore it is impossible to read it simultaneously.
It would be much easier in your script preprocess would not write to the command window by disp or implicitly by omitting the trailing semicolon, but uses a specific output function. Then this function could be modified to add a copy of the output to the wanted uicontrol also.
3 Comments
More Answers (0)
See Also
Categories
Find more on Migrate GUIDE Apps 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!