% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.text5,'string','dcm2vol.m')set(handles.text2,'string','PROCESSING IN PROGRESS. PLEASE WAIT')pause(1)din = 'C:\Users\ying0018\Documents\MATLAB\Original_DICOM';dcm = dcm2vol(din)assignin('base','din',din)assignin('base','dcm',dcm)setappdata(0,'pushbutton1',dcm);set(handles.text2,'string','PROCESSING COMPLETED SUCCESSFULLY')%*From pushbutton1, i can get the value for dcm which is -2084*
function pushbutton4_Callback(hObject, eventdata, handles)% hObject handle to pushbutton4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)dcm = getappdata(0,'pushbutton1');MR = getappdata(0,'pushbutton2');set(handles.text5,'string','Rightmaskdcm.m')set(handles.text2,'string','PROCESSING IN PROGRESS. PLEASE WAIT')pause(1)dcm = double(dcm)setappdata(0,'pushbutton4',dcm);pause(1)dcmmR = Rightmaskdcm(dcm,MR)assignin('base','dcm',dcm)assignin('base','dcmmR',dcmmR)setappdata(0,'pushbutton4',dcmmR);set(handles.text2,'string','PROCESSING COMPLETED SUCCESSFULLY')
assignin correctly returns the value of the new dcm after double which is -2084. However setappdata set the new dcm to 0. which does not make sense. In the workspace: dcm = 512x512x481 (int16) new dcm = 512x512x481 (double) why setappdata cannot capture the values of double dcm?
Best Answer