Filter löschen
Filter löschen

Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

Figure/Axes Not Refreshing in GUI

1 Ansicht (letzte 30 Tage)
Ed
Ed am 17 Jan. 2013
I understand this may be a common issue with now solution, but I have a deliverable long overdue and I'd like to present the customer with a working executable (I will use Compiler to deliver as an executable.)
I have a pushbutton "Plot Simulated Scan" that runs some scalar manipulation of a large matrix (3,000 x 3,000 of type double) and plots as either an imagesc or surface plot. The problem is that when I select various parameters and run the "Plot Simulated Scan" routine the calculations occur (memory use spikes and drops like normal), but the axes do not refresh.
I have tried the drawnow (expose/update) commands as well as clearing everything.
Is Matlab simply not capable of reliably displaying and refreshing plots in a GUI? I'm running version 2012B.
Thanks in advance.
Code:
% --- 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;
case 'Multiple Point-sources'
HeightMesh100=MultiHeightMesh100;
HeightMesh300=MultiHeightMesh300;
HeightMesh500=MultiHeightMesh500;
HeightMesh700=MultiHeightMesh700;
HeightMesh1000=MultiHeightMesh1000;
case 'Gaussian Distribution'
HeightMesh100=GaussHeightMesh100;
HeightMesh300=GaussHeightMesh300;
HeightMesh500=GaussHeightMesh500;
HeightMesh700=GaussHeightMesh700;
HeightMesh1000=GaussHeightMesh1000;
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'
DetEff=0.3;
DetSA=4*pi*(1.5*2.54)^2;
DetScale=DetEff*DetSA;
DetBG=200;
case '2"x2" NaI'
DetEff=0.25;
DetSA=4*pi*(1*2.54)^2;
DetScale=DetEff*DetSA;
DetBG=100;
case '1"x1" NaI'
DetEff=0.2;
DetSA=4*pi*(.5*2.54)^2;
DetScale=DetEff*DetSA;
DetBG=30;
case 'GM Tube'
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=axis_valsx;
elseif scan_speed==2
mesh=3000/50;
gridspace=50;
axis_valsx=linspace(1,3000,mesh);
axis_valsy=axis_valsx;
elseif scan_speed==3
mesh=3000/100;
gridspace=100;
axis_valsx=linspace(1,3000,mesh);
axis_valsy=axis_valsx;
elseif scan_speed==4
mesh=3000/150;
gridspace=150;
axis_valsx=linspace(1,3000,mesh);
axis_valsy=axis_valsx;
elseif scan_speed==5
mesh=3000/200;
gridspace=200;
axis_valsx=linspace(1,3000,mesh);
axis_valsy=axis_valsx;
end
PoissonMesh=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);
RealCount=Counts+DetBG;
PoissCount=poissrnd(RealCount);
PoissonMesh(i,j)=PoissCount;
end
end
PoissonMesh=flipud(PoissonMesh);
Plottypestr = get(handles.Plottype, 'String');
Plottypeval = get(handles.Plottype, 'Value');
switch Plottypestr{Plottypeval};
case 'Two Dimensional'
axes(handles.axes);
imagesc(axis_valsx,axis_valsy,PoissonMesh);
colormap(hot);
colorbar;
title(colorbar,'Counts');
case 'Three Dimensional'
axes(handles.axes);
surface(axis_valsx,axis_valsy,PoissonMesh);
view(-10,10);
colormap(hot);
colorbar;
title(colorbar,'Counts');
end
drawnow expose update;
clear PoissonMesh STstr STval HeightMesh100 HeightMesh300 HeightMesh500
clear HeightMesh700 HeightMesh1000 HeightMesh x y z Suppstr Suppval
clear SHstr SHval SSstr SSval Scanstr Scanval scan_speed DTstr DTval
clear detector_type DetEff DetSA DetScale DetBG Source_Mesh mesh gridspace
clear axis_valsx axis_valsy IdealScanMesh PoissonMesh Plottypestr
clear Plottypeval
%-----------------------------------------------------
  1 Kommentar
Jan
Jan am 18 Jan. 2013
Usually excessively using CLEAR command is not useful at all, but only confusing. At the end of a function, clear'ing is only a waste of time.
I cannot understand what the large piece of your code does, because I do not know the the meaning and values of the variables. I've never had the impression that Matlab has problems with displaying images, when it has at least 0.02 seconds time for updating: pause(0.02). Therefore I would still assume a programming bug: Are you sure that the values are changed? A general rule is: Always add an OTHERWISE or ELSE branch to catch not considered switchs.

Antworten (0)

Diese Frage ist geschlossen.

Community Treasure Hunt

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

Start Hunting!

Translated by