我是 gui matlab 的新手。我创建了一个 gui。在其中,我使用名为 process 的按钮进行一些计算,结果以名为 texthistory
的静态文本显示。每次,我都会进行新的计算,新结果会显示在文本历史记录中,以前的数据会被删除。但我希望它们都出现在文本历史中。我该怎么做?
谢谢。这是我的代码:
function processpb_Callback(hObject, eventdata, handles)
% hObject handle to processpb (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
if isempty(handles.D)
warndlg('Please Insert Image','Warning');
elseif handles.flag(1)~=0 ;
else
Val = get(handles.psf1,'String');
Bw = im2bw(handles.D);
s = regionprops(Bw, handles.D, 'Centroid');
sx1 = round(s.Centroid(1));
sy1 = round(s.Centroid(2));
roi2 = handles.roi/2;
i = (sx1-((roi2)-1)):(sx1+ roi2);
j = (sy1-((roi2)-1)):(sy1+ roi2);
ROI = (handles.D(i,j));
ROI = (2^16-1)-ROI;
handles.avg1 = (sum(ROI(:)/str2num(Val))./((handles.roi).^2));
end
a1=['Reference ROI pixel value at 100 MU: ',num2str(handles.avg)];
a2=['Image ROI pixel value at 100 MU: ',num2str(handles.avg1)];
clock=[num2str(date), ' --- ',num2str(handles.c(4)),': ',num2str(handles.c(5))];
popval1=get(handles.popupmenu1,'Value');
strval1=get(handles.popupmenu1,'String');
type1=strval1{popval1};
popval2=get(handles.popupmenu2,'Value');
strval2=get(handles.popupmenu2,'String');
type2=strval2{popval2};
A={clock ,type1,type2, a1,a2}';
set(handles.texthistory,'String',A)
guidata(hObject,handles);
你可以做这样的事情
previous_text = get(handles.texthistory,'String');
new_text = sprintf('%sn%s',previous_text,A);
set(handles.texthistory,'String', new_text);