I have App with a Plot button that executes a plotting routine when it is pushed. The PlotPushDown callback creates a figure with several subplots. For each plot command i return the plot handle and store it. Upon closing the figure, I would like to return the latest plot handles. I am using BrushData, so the plot handles can change with user interaction. Upon closing the figure I need to access the latest BrushData for more data processing.
function PlotButtonPushed(app, event)
f = figure('CloseRequestFcn',@getBrushData); hold on; brush on;
if any(strcmp(app.ListBox.Value,'User Input'))
n = length(app.ListBox.Value) - 1;
else
n = length(app.ListBox.Value);
end
switch app.DropDown.Value
case 'Pressure'
for i = 1:length(app.ListBox.Value)
switch app.ListBox.Value{i}
case 'TRAP'
subplot(n,1,i)
h{i} = plot(app.allData.trapTime,app.allData.trapPressure,'LineWidth',2);
h{i}.Tag = 'Time';
title('TRAP')
xlabel('Time (s)')
ylabel('Pressure (psia)')
xlim([-10 10])
grid on;
tmp{i} = zeros(1,length(app.allData.trapTime));
tmp{i}(app.t0Data.trapIDX) = 1;
h{i}.BrushData = tmp{i};
case 'Balloon'
subplot(n,1,i)
h{i} = plot(app.allData.balloonAltitude,app.allData.balloonPressure,'LineWidth',2);
h{i}.Tag = 'Altitude';
title('Balloon Data')
xlabel('Altitude (ft)')
ylabel('Pressure (psia)')
xlim([0 600])
grid on;
case 'Measured'
subplot(n,1,i)
h{i} = plot(app.allData.measurementTime,app.allData.measurementPressure,'LineWidth',2);
h{i}.Tag = 'Time';
title('Measurement Data')
xlabel('Time (s)')
ylabel('Pressure (psia)')
xlim([-10 10])
grid on;
tmp{i} = zeros(1,length(app.allData.measurementTime));
tmp{i}(app.t0Data.measurementIDX) = 1;
h{i}.BrushData = tmp{i};
case 'User Input'
for j = 1:length(app.ListBox.Value) - 1
subplot(n,1,j); hold on;
if strcmp(h{j}.Tag,'Time')
plot(0,app.pInput.Value,'o','MarkerSize',10,'MarkerEdgeColor','r','MarkerFaceColor','g')
elseif strcmp(h{j}.Tag,'Altitude')
plot(app.t0Data.Altitude,app.pInput.Value,'o','MarkerSize',10,'MarkerEdgeColor','r','MarkerFaceColor','g')
end
end
end
end
case 'Temperature'
case 'Wind Speed'
case 'Wind Direction'
case 'Relative Humidity'
case 'Dew Point'
end
waitfor(f);
end
function getBrushData(src,evt)
disp('aaa')
closereq
end