Clear Filters
Clear Filters

GUI Won't Plot Two Surface Plots Simultaneously - Lack of Memory?

3 views (last 30 days)
So I have a GUI which plots a large matrix as either an imagesc plot or surface plot (3,000 x 3,000) matrix.
I also plot some source-points as scatter(x,y), except one instance where the source input was a gaussian source distribution consisting of 72001 source locations, each with a weight (x,y,z) as 72001 rows with 3 columns.
When I run either of the single/multi-source plots, the surface plot works fine (last lines of code) and the scatter plot is displayed. When I run the Gaussian-source plots, only the imagesc plot function works (I'm also displaying the scatter3 plot of the Gaussian sources). Also, when I comment out tthe scatter3 source plot, the surface plot works fine.
Could it be a memory issue? I don't get errors, Matlabs just hangs...
Code:
function varargout = DoseMapperGUI(varargin)
% DOSEMAPPERGUI MATLAB code for DoseMapperGUI.fig
% DOSEMAPPERGUI, by itself, creates a new DOSEMAPPERGUI or raises the existing
% singleton*.
%
% H = DOSEMAPPERGUI returns the handle to a new DOSEMAPPERGUI or the handle to
% the existing singleton*.
%
% DOSEMAPPERGUI('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in DOSEMAPPERGUI.M with the given input arguments.
%
% DOSEMAPPERGUI('Property','Value',...) creates a new DOSEMAPPERGUI or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before DoseMapperGUI_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to DoseMapperGUI_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help DoseMapperGUI
% Last Modified by GUIDE v2.5 09-Jan-2013 12:52:54
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @DoseMapperGUI_OpeningFcn, ...
'gui_OutputFcn', @DoseMapperGUI_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before DoseMapperGUI is made visible.
function DoseMapperGUI_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to DoseMapperGUI (see VARARGIN)
% Choose default command line output for DoseMapperGUI
handles.output = hObject;
handles.data_loaded=0;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes DoseMapperGUI wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = DoseMapperGUI_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --- Executes on selection change in source_type.
function source_type_Callback(hObject, eventdata, handles)
% hObject handle to source_type (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns source_type contents as cell array
% contents{get(hObject,'Value')} returns selected item from source_type
% --- Executes during object creation, after setting all properties.
function source_type_CreateFcn(hObject, eventdata, handles)
% hObject handle to source_type (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: listbox controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on selection change in source_strength.
function source_strength_Callback(hObject, eventdata, handles)
% hObject handle to source_strength (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns source_strength contents as cell array
% contents{get(hObject,'Value')} returns selected item from source_strength
% --- Executes during object creation, after setting all properties.
function source_strength_CreateFcn(hObject, eventdata, handles)
% hObject handle to source_strength (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: listbox controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on selection change in detector_type.
function detector_type_Callback(hObject, eventdata, handles)
% hObject handle to detector_type (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns detector_type contents as cell array
% contents{get(hObject,'Value')} returns selected item from detector_type
% --- Executes during object creation, after setting all properties.
function detector_type_CreateFcn(hObject, eventdata, handles)
% hObject handle to detector_type (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: listbox controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on selection change in scan_speed.
function scan_speed_Callback(hObject, eventdata, handles)
% hObject handle to scan_speed (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns scan_speed contents as cell array
% contents{get(hObject,'Value')} returns selected item from scan_speed
% --- Executes during object creation, after setting all properties.
function scan_speed_CreateFcn(hObject, eventdata, handles)
% hObject handle to scan_speed (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: listbox controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on selection change in scan_height.
function scan_height_Callback(hObject, eventdata, handles)
% hObject handle to scan_height (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA
% Hints: contents = cellstr(get(hObject,'String')) returns scan_height contents as cell array
% contents{get(hObject,'Value')} returns selected item from scan_height
% --- Executes during object creation, after setting all properties.
function scan_height_CreateFcn(hObject, eventdata, handles)
% hObject handle to scan_height (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: listbox controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on selection change in Plottype.
function Plottype_Callback(hObject, eventdata, handles)
% hObject handle to Plottype (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns Plottype contents as cell array
% contents{get(hObject,'Value')} returns selected item from Plottype
% --- Executes during object creation, after setting all properties.
function Plottype_CreateFcn(hObject, eventdata, handles)
% hObject handle to Plottype (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in runmapper.
function runmapper_Callback(hObject, eventdata, handles)
% hObject handle to runmapper (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Load MCNP Pre-Calculated Mesh Data
% MCNPdata.mat must be located in the active directory
if (handles.data_loaded==0)
load('MCNPdata.mat');
handles.data_loaded=1;
end
%global HeightMesh100;
%global HeightMesh300;
%global HeightMesh500;
%global HeightMesh700;
%global HeightMesh1000;
%global Interp_Distance;
%global Interp_MCNP_Flux;
STstr = get(handles.source_type,'String');
STval = get(handles.source_type,'Value');
% Set current data to the selected data set.
switch STstr{STval};
case 'Single Point-source'
HeightMesh100=SingleHeightMesh100;
HeightMesh300=SingleHeightMesh300;
HeightMesh500=SingleHeightMesh500;
HeightMesh700=SingleHeightMesh700;
HeightMesh1000=SingleHeightMesh1000;
x = SingleSourceCoords(:,1);
y = SingleSourceCoords(:,2);
axes(handles.SourceAxes);
scatter(x,y,1,'filled');
xlim([0 3000])
ylim([0 3000])
case 'Multiple Point-sources'
HeightMesh100=MultiHeightMesh100;
HeightMesh300=MultiHeightMesh300;
HeightMesh500=MultiHeightMesh500;
HeightMesh700=MultiHeightMesh700;
HeightMesh1000=MultiHeightMesh1000;
x = MultiSourceCoords(:,1);
y = MultiSourceCoords(:,2);
axes(handles.SourceAxes);
scatter(x,y,6,'filled');
xlim([0 3000])
ylim([0 3000])
case 'Gaussian Distribution'
HeightMesh100=GaussHeightMesh100;
HeightMesh300=GaussHeightMesh300;
HeightMesh500=GaussHeightMesh500;
HeightMesh700=GaussHeightMesh700;
HeightMesh1000=GaussHeightMesh1000;
%x = GaussSourceCoords(:,1);
%y = GaussSourceCoords(:,2);
%z = GaussSourceCoords(:,3);
%axes(handles.SourceAxes);
%scatter3(x,y,z,1,z);
%xlim([0 3000])
%ylim([0 3000])
end
SHstr = get(handles.scan_height, 'String');
SHval = get(handles.scan_height,'Value');
% Set current data to the selected data set.
switch SHstr{SHval};
case '100ft'
HeightMesh=HeightMesh100;
case '300ft'
HeightMesh=HeightMesh300;
case '500ft'
HeightMesh=HeightMesh500;
case '700ft'
HeightMesh=HeightMesh700;
case '1,000ft'
HeightMesh=HeightMesh1000;
end
SSstr = get(handles.source_strength, 'String');
SSval = get(handles.source_strength,'Value');
% Set current data to the selected data set.
switch SSstr{SSval};
case '1Rem/hr'
Source_Mesh=3.7E+10*3.5*HeightMesh;
case '3Rem/hr'
Source_Mesh=3.7E+10*10*HeightMesh;
case '5Rem/hr'
Source_Mesh=3.7E+10*17*HeightMesh;
end
Scanstr = get(handles.scan_speed, 'String');
Scanval = get(handles.scan_speed,'Value');
% Set current data to the selected data set.
switch Scanstr{Scanval};
case '12knots (20fps)'
scan_speed=1;
case '30knots (50fps)'
scan_speed=2;
case '59knots (100fps)'
scan_speed=3;
case '89knots (150fps)'
scan_speed=4;
case '118knots (200fps)'
scan_speed=5;
end
DTstr = get(handles.detector_type, 'String');
DTval = get(handles.detector_type,'Value');
% Set current data to the selected data set.
switch DTstr{DTval};
case '3"x3" NaI'
detector_type=1;
case '2"x2" NaI'
detector_type=2;
case '1"x1" NaI'
detector_type=3;
case 'GM Tube'
detector_type=4;
end
if detector_type==1
DetEff=0.3;
DetSA=4*pi*(1.5*2.54)^2;
DetScale=DetEff*DetSA;
DetBG=200;
elseif detector_type==2
DetEff=0.25;
DetSA=4*pi*(1*2.54)^2;
DetScale=DetEff*DetSA;
DetBG=100;
elseif detector_type==3
DetEff=0.2;
DetSA=4*pi*(.5*2.54)^2;
DetScale=DetEff*DetSA;
DetBG=30;
elseif detector_type==4
DetEff=0.02;
DetSA=3;
DetScale=DetEff*DetSA;
DetBG=1;
end
NetCPSMesh=Source_Mesh*DetScale;
if scan_speed==1
mesh=3000/20;
gridspace=20;
axis_valsx=linspace(1,3000,mesh);
axis_valsy=flipud(axis_valsx);
elseif scan_speed==2
mesh=3000/50;
gridspace=50;
axis_valsx=linspace(1,3000,mesh);
axis_valsy=flipud(axis_valsx);
elseif scan_speed==3
mesh=3000/100;
gridspace=100;
axis_valsx=linspace(1,3000,mesh);
axis_valsy=flipud(axis_valsx);
elseif scan_speed==4
mesh=3000/150;
gridspace=150;
axis_valsx=linspace(1,3000,mesh);
axis_valsy=flipud(axis_valsx);
elseif scan_speed==5
mesh=3000/200;
gridspace=200;
axis_valsx=linspace(1,3000,mesh);
axis_valsy=flipud(axis_valsx);
end
IdealScanMesh=zeros(mesh,mesh);
for i=1:1:mesh
for j=1:1:mesh
amax=i*gridspace;
amin=amax-gridspace+1;
b=(j*gridspace)-(gridspace/2);
CPSIntegral=NetCPSMesh(amin:amax,b);
Counts=trapz(CPSIntegral/gridspace);
IdealScanMesh(i,j)=Counts;
end
end
PoissonMesh=zeros(mesh,mesh);
for i=1:1:mesh
for j=1:1:mesh
count=IdealScanMesh(i,j)+DetBG;
RealCount=poissrnd(count);
PoissonMesh(i,j)=RealCount;
end
end
Scanstr = get(handles.Plottype, 'String');
Scanval = get(handles.Plottype,'Value');
% Set current data to the selected data set.
switch Scanstr{Scanval};
case 'Image'
axes(handles.axes);
imagesc(axis_valsx,axis_valsy,PoissonMesh);
colormap(hot);
colorbar;
title(colorbar,'Counts');
case '3D'
axes(handles.axes);
surface(axis_valsx,axis_valsy,PoissonMesh);
colormap(hot);
colorbar;
title(colorbar,'Counts');
end
% --------------------------------------------------------------------
function Untitled_1_Callback(hObject, eventdata, handles)
% hObject handle to Untitled_1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
  1 Comment
Ed
Ed on 10 Jan 2013
So I changed the source-type plot back to a colormapped scatter plot, and waited a long time for the surface plot to update. It finally did, and when I used the tilt/rotate tool on the surface plot, I got this error:
No appropriate method, property, or field modeWindowButtonDownFcn for class handle.handle.
Error in uitools.uimode/modeControl>localModeWindowButtonDownFcn (line 151) hThis.modeWindowButtonDownFcn(hFig,evd,hThis,newValue);
Error while evaluating figure WindowButtonDownFcn

Sign in to comment.

Answers (1)

Ed
Ed on 11 Jan 2013
Well I've updated my code to allow suppression of the first plot, but now none of my 3D surface plots are working?
% --- Executes on button press in runmapper.
function runmapper_Callback(hObject, eventdata, handles)
% hObject handle to runmapper (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Load MCNP Pre-Calculated Mesh Data
% MCNPdata.mat must be located in the active directory
if (handles.data_loaded==0)
load('MCNPdata.mat');
handles.data_loaded=1;
end
STstr = get(handles.source_type,'String');
STval = get(handles.source_type,'Value');
switch STstr{STval};
case 'Single Point-source'
HeightMesh100=SingleHeightMesh100;
HeightMesh300=SingleHeightMesh300;
HeightMesh500=SingleHeightMesh500;
HeightMesh700=SingleHeightMesh700;
HeightMesh1000=SingleHeightMesh1000;
x = SingleSourceCoords(:,1);
y = SingleSourceCoords(:,2);
axes(handles.SourceAxes);
scatter(x,y,6,'filled');
xlim([0 3000])
ylim([0 3000])
case 'Multiple Point-sources'
HeightMesh100=MultiHeightMesh100;
HeightMesh300=MultiHeightMesh300;
HeightMesh500=MultiHeightMesh500;
HeightMesh700=MultiHeightMesh700;
HeightMesh1000=MultiHeightMesh1000;
x = MultiSourceCoords(:,1);
y = MultiSourceCoords(:,2);
axes(handles.SourceAxes);
scatter(x,y,6,'filled');
xlim([0 3000])
ylim([0 3000])
case 'Gaussian Distribution'
HeightMesh100=GaussHeightMesh100;
HeightMesh300=GaussHeightMesh300;
HeightMesh500=GaussHeightMesh500;
HeightMesh700=GaussHeightMesh700;
HeightMesh1000=GaussHeightMesh1000;
Suppstr = get(handles.SourceSuppress,'String');
Suppval = get(handles.SourceSuppress,'Value');
switch Suppstr{Suppval};
case 'Yes'
wait(1);
case 'No'
x = GaussSourceCoords(:,1);
y = GaussSourceCoords(:,2);
z = GaussSourceCoords(:,3);
axes(handles.SourceAxes);
scatter(x,y,1,z);
colormap('hot');
xlim([0 3000])
ylim([0 3000])
end
end
SHstr = get(handles.scan_height, 'String');
SHval = get(handles.scan_height,'Value');
switch SHstr{SHval};
case '100ft'
HeightMesh=HeightMesh100;
case '300ft'
HeightMesh=HeightMesh300;
case '500ft'
HeightMesh=HeightMesh500;
case '700ft'
HeightMesh=HeightMesh700;
case '1,000ft'
HeightMesh=HeightMesh1000;
end
SSstr = get(handles.source_strength, 'String');
SSval = get(handles.source_strength,'Value');
switch SSstr{SSval};
case '1Rem/hr'
Source_Mesh=3.7E+10*3.5*HeightMesh;
case '3Rem/hr'
Source_Mesh=3.7E+10*10*HeightMesh;
case '5Rem/hr'
Source_Mesh=3.7E+10*17*HeightMesh;
end
Scanstr = get(handles.scan_speed, 'String');
Scanval = get(handles.scan_speed,'Value');
switch Scanstr{Scanval};
case '12knots (20fps)'
scan_speed=1;
case '30knots (50fps)'
scan_speed=2;
case '59knots (100fps)'
scan_speed=3;
case '89knots (150fps)'
scan_speed=4;
case '118knots (200fps)'
scan_speed=5;
end
DTstr = get(handles.detector_type, 'String');
DTval = get(handles.detector_type,'Value');
switch DTstr{DTval};
case '3"x3" NaI'
detector_type=1;
case '2"x2" NaI'
detector_type=2;
case '1"x1" NaI'
detector_type=3;
case 'GM Tube'
detector_type=4;
end
if detector_type==1
DetEff=0.3;
DetSA=4*pi*(1.5*2.54)^2;
DetScale=DetEff*DetSA;
DetBG=200;
elseif detector_type==2
DetEff=0.25;
DetSA=4*pi*(1*2.54)^2;
DetScale=DetEff*DetSA;
DetBG=100;
elseif detector_type==3
DetEff=0.2;
DetSA=4*pi*(.5*2.54)^2;
DetScale=DetEff*DetSA;
DetBG=30;
elseif detector_type==4
DetEff=0.02;
DetSA=3;
DetScale=DetEff*DetSA;
DetBG=1;
end
NetCPSMesh=Source_Mesh*DetScale;
if scan_speed==1
mesh=3000/20;
gridspace=20;
axis_valsx=linspace(1,3000,mesh);
axis_valsy=flipud(axis_valsx);
elseif scan_speed==2
mesh=3000/50;
gridspace=50;
axis_valsx=linspace(1,3000,mesh);
axis_valsy=flipud(axis_valsx);
elseif scan_speed==3
mesh=3000/100;
gridspace=100;
axis_valsx=linspace(1,3000,mesh);
axis_valsy=flipud(axis_valsx);
elseif scan_speed==4
mesh=3000/150;
gridspace=150;
axis_valsx=linspace(1,3000,mesh);
axis_valsy=flipud(axis_valsx);
elseif scan_speed==5
mesh=3000/200;
gridspace=200;
axis_valsx=linspace(1,3000,mesh);
axis_valsy=flipud(axis_valsx);
end
IdealScanMesh=zeros(mesh,mesh);
for i=1:1:mesh
for j=1:1:mesh
amax=i*gridspace;
amin=amax-gridspace+1;
b=(j*gridspace)-(gridspace/2);
CPSIntegral=NetCPSMesh(amin:amax,b);
Counts=trapz(CPSIntegral/gridspace);
IdealScanMesh(i,j)=Counts;
end
end
PoissonMesh=zeros(mesh,mesh);
for i=1:1:mesh
for j=1:1:mesh
count=IdealScanMesh(i,j)+DetBG;
RealCount=poissrnd(count);
PoissonMesh(i,j)=RealCount;
end
end
PTstr = get(handles.Plottype,'String');
PTval = get(handles.Plottype,'Value');
switch PTstr{PTval};
case '2D'
axes(handles.axes);
imagesc(axis_valsx,axis_valsy,PoissonMesh);
colormap(hot);
colorbar;
title(colorbar,'Counts');
case '3D'
axes(handles.axes);
surface(axis_valsx,axis_valsy,PoissonMesh);
colormap(hot);
colorbar;
title(colorbar,'Counts');
end

Categories

Find more on Graphics Object Properties 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!