I noted that I have a callback for the UI Figure CloseRequestFcn delete(gcf) which I am not able to delete. I see a lot of comments in the Matlab FAQs that talk about removing callbacks in the code browser, however this callback is shown in the Component Browser. When I highlight the UI figure it lists the figure properties and also callbacks, one of which is the CloseRequestFcn howver when I set it to noCallback it does not change. Any thoughts on how to change or remove this callback?
App Designer has error in generated code
4 次查看(过去 30 天)
显示 更早的评论
App designer places code (grayed out) that shows an error. I will note that the code ran fine before I saved and closed it out and then later restarted the app. I think the issue might be related to the fact that I had a callback that used the delete function which is used to close the app.
The line that show the syntax error is the following and bold in the full code listing:
app.RawdataPlotterAppUIFigure.CloseRequestFcn = createCallbackFcn(app, @delete(gcf), true);
Full code below:
classdef RawDataPlotterNew < matlab.apps.AppBase
% Properties that correspond to app components
properties (Access = public)
RawdataPlotterAppUIFigure matlab.ui.Figure
GridLayout matlab.ui.container.GridLayout
LeftPanel matlab.ui.container.Panel
ControlPanel matlab.ui.container.Panel
SelectDataFileButton matlab.ui.control.Button
QuitButton matlab.ui.control.Button
ChannelSelectPanel matlab.ui.container.Panel
Select355CheckBox matlab.ui.control.CheckBox
Select532CheckBox matlab.ui.control.CheckBox
Select1064CheckBox matlab.ui.control.CheckBox
DelaysEditField matlab.ui.control.NumericEditField
DelaysEditFieldLabel matlab.ui.control.Label
StepDownButton matlab.ui.control.Button
AltMaxEditField matlab.ui.control.NumericEditField
AltMaxEditFieldLabel matlab.ui.control.Label
AltMinEditField matlab.ui.control.NumericEditField
AltMinEditFieldLabel matlab.ui.control.Label
CountsMaxEditField matlab.ui.control.NumericEditField
CountsMaxEditFieldLabel matlab.ui.control.Label
CountsMinEditField matlab.ui.control.NumericEditField
CountsMinEditFieldLabel matlab.ui.control.Label
AutoScaleYCheckBox matlab.ui.control.CheckBox
AutoScaleXCheckBox matlab.ui.control.CheckBox
LegendCheckBox matlab.ui.control.CheckBox
LogScaleCheckBox matlab.ui.control.CheckBox
RangeSquaredCheckBox matlab.ui.control.CheckBox
RunButton matlab.ui.control.StateButton
StepUpButton matlab.ui.control.Button
RecordEditField matlab.ui.control.NumericEditField
RecordEditFieldLabel matlab.ui.control.Label
TimeEditField matlab.ui.control.NumericEditField
TimeEditFieldLabel matlab.ui.control.Label
Channel4DropDown matlab.ui.control.DropDown
Channel4DropDownLabel matlab.ui.control.Label
Channel3DropDown matlab.ui.control.DropDown
Channel3DropDownLabel matlab.ui.control.Label
Channel2DropDown matlab.ui.control.DropDown
Channel2DropDownLabel matlab.ui.control.Label
Channel1DropDown matlab.ui.control.DropDown
Channel1DropDownLabel matlab.ui.control.Label
RightPanel matlab.ui.container.Panel
Panel4 matlab.ui.container.Panel
StatusEditField matlab.ui.control.EditField
StatusEditFieldLabel matlab.ui.control.Label
PathnameEditField matlab.ui.control.EditField
PathnameEditFieldLabel matlab.ui.control.Label
FilenameEditField matlab.ui.control.EditField
FilenameEditFieldLabel matlab.ui.control.Label
Panel3 matlab.ui.container.Panel
UIAxes matlab.ui.control.UIAxes
end
% Properties that correspond to apps with auto-reflow
properties (Access = private)
onePanelWidth = 576;
end
properties (Access = private)
FileName; % File for rawdata file being plotted
PathName; % Path for rawdata file being plotted
FullFileName; %Full filename
ChannelNames; %Names of the channels in data file
Altitude; %Altitude from raw data file
TimeUT; %time from rawdata file
SelectedChannels; %array of selected channels
CurrentRecord; %record index
CurrentTimeUT; %current time of data record
data; % data from selected channels
range; % range data for all PMT channels
range50; % range data for all APD channels
NumChannels = 4;
goodFileSelected = 0; %toggle to make sure a good file is selected
end
methods (Access = private)
function updatePlot(app)
getSelectedChannels(app)
for idx=1:app.NumChannels
if app.RangeSquaredCheckBox.Value
x = squeeze(app.data(:,app.CurrentRecord,idx));
else
if contains(app.SelectedChannels(idx),'1064')
x = squeeze(app.data(:,app.CurrentRecord,idx))./(app.range50(:,app.CurrentRecord)).^2;
else
x = squeeze(app.data(:,app.CurrentRecord,idx))./(app.range(:,app.CurrentRecord)).^2;
end
end
plot(app.UIAxes,x,app.Altitude);
hold(app.UIAxes,'on')
end
hold(app.UIAxes,'off')
%scale axes
if app.AutoScaleXCheckBox.Value
xlim(app.UIAxes,[0,2^16]);
else
xlim(app.UIAxes, [app.CountsMinEditField.Value,app.CountsMaxEditField.Value]);
end
if app.AutoScaleYCheckBox.Value
ylim(app.UIAxes, [min(app.Altitude),max(app.Altitude)]);
else
ylim(app.UIAxes, [app.AltMinEditField.Value,app.AltMaxEditField.Value]);
end
%check log scale
if app.LogScaleCheckBox.Value == 1
xscale(app.UIAxes,"log");
else
xscale(app.UIAxes,"linear");
end
%add legend
if app.LegendCheckBox.Value
legend(app.UIAxes,app.SelectedChannels,'Interpreter', 'none')
else
legend(app.UIAxes,'off')
end
drawnow;
end
function getSelectedChannels(app)
channel(1) = app.Channel1DropDown.ValueIndex;
channel(2) = app.Channel2DropDown.ValueIndex;
channel(3) = app.Channel3DropDown.ValueIndex;
channel(4) = app.Channel4DropDown.ValueIndex;
for idx=1:app.NumChannels
app.SelectedChannels{idx} = app.ChannelNames{channel(idx)};
end
end
function updateData(app)
if app.goodFileSelected
%always update selected channels
getSelectedChannels(app);
for idx=1:app.NumChannels
if contains(app.SelectedChannels{idx},'None')
app.data(:,:,idx) = NaN(size(app.Altitude,1),size(app.TimeUT,2));
else
dataName = ['/CLDSData/',app.SelectedChannels{idx}];
app.data(:,:,idx) = h5read(app.FullFileName,dataName);
end
end
else
app.StatusEditField.Value = 'Not correct type of data file (LBW or HBW)';
end
end
function updateDataSingleChannel(app,idx)
if app.goodFileSelected
%always update selected channels
getSelectedChannels(app);
if contains(app.SelectedChannels{idx},'None')
app.data(:,:,idx) = NaN(size(app.Altitude,1),size(app.TimeUT,2));
else
dataName = ['/CLDSData/',app.SelectedChannels{idx}];
app.data(:,:,idx) = h5read(app.FullFileName,dataName);
end
else
app.StatusEditField.Value = 'Not correct type of data file (LBW or HBW)';
end
end
end
% Callbacks that handle component events
methods (Access = private)
% Code that executes after component creation
function startupFcn(app)
SelectDataFileButtonPushed(app, [])
end
% Button pushed function: QuitButton
function QuitButtonPushed(app, event)
delete(app)
end
% Button pushed function: SelectDataFileButton
function SelectDataFileButtonPushed(app, event)
defname = '/Users/Shared/Data/';
[app.FileName,app.PathName] = uigetfile('.h5','Select H5 File',defname);
app.FilenameEditField.Value = app.FileName;
app.PathnameEditField.Value = app.PathName;
app.FullFileName = fullfile(app.PathName,app.FileName);
%get channel names and populate the dropdown lists
%do try catch to see if data file is correct
try
app.ChannelNames = h5read(app.FullFileName,'/Channel_Names');
selectIdx = contains(app.ChannelNames,'high');
app.ChannelNames = app.ChannelNames(selectIdx);
app.ChannelNames = [{'None'};app.ChannelNames];
app.Channel1DropDown.Items = app.ChannelNames;
app.Channel2DropDown.Items = app.ChannelNames;
app.Channel3DropDown.Items = app.ChannelNames;
app.Channel4DropDown.Items = app.ChannelNames;
catch
app.StatusEditField.Value = 'Not correct type of data file (LBW or HBW)';
end
%load in the altitude and time data
try
app.Altitude = h5read(app.FullFileName,'/DataProducts/Altitude')/1000;
app.TimeUT = h5read(app.FullFileName,'/Nav_Data/gps_time');
app.CurrentRecord = 1;
app.CurrentTimeUT = app.TimeUT(app.CurrentRecord);
app.TimeEditField.Value = app.TimeUT(app.CurrentRecord);
app.RecordEditField.Value = app.CurrentRecord;
app.goodFileSelected = 1;
catch
app.StatusEditField.Value = 'Issue reading altitude or time from data file';
end
%get range data
app.range = h5read(app.FullFileName,'/UserInput/range_interp');
app.range50 = h5read(app.FullFileName,'/UserInput/range50_interp');
%initialize data array to NaN
app.data = NaN(size(app.Altitude,1),size(app.TimeUT,2),app.NumChannels);
%set limits on record and time values
app.RecordEditField.Limits = [1,size(app.TimeUT,2)];
app.TimeEditField.Limits = [min(app.TimeUT),max(app.TimeUT)];
%update data
updateData(app);
%plot data
updatePlot(app);
end
% Value changed function: RecordEditField
function RecordEditFieldValueChanged(app, event)
value = app.RecordEditField.Value;
app.CurrentRecord = value;
app.TimeEditField.Value = app.TimeUT(app.CurrentRecord);
updatePlot(app)
end
% Value changed function: TimeEditField
function TimeEditFieldValueChanged(app, event)
value = app.TimeEditField.Value;
if value <= app.TimeUT(1,end)
idx = find(app.TimeUT>=value,1,'first');
else
idx = size(app.TimeUT,2);
end
app.CurrentTimeUT = app.TimeUT(idx);
app.RecordValue.Value = idx;
updatePlot(app)
end
% Value changed function: Channel1DropDown
function Channel1DropDownValueChanged(app, event)
updateDataSingleChannel(app,1);
updatePlot(app);
end
% Value changed function: Channel2DropDown
function Channel2DropDownValueChanged(app, event)
updateDataSingleChannel(app,2);
updatePlot(app);
end
% Value changed function: Channel3DropDown
function Channel3DropDownValueChanged(app, event)
updateDataSingleChannel(app,3);
updatePlot(app);
end
% Value changed function: Channel4DropDown
function Channel4DropDownValueChanged(app, event)
updateDataSingleChannel(app,4);
updatePlot(app);
end
% Value changed function: LogScaleCheckBox
function LogScaleCheckBoxValueChanged(app, event)
updatePlot(app);
end
% Value changed function: LegendCheckBox
function LegendCheckBoxValueChanged(app, event)
updatePlot(app);
end
% Value changed function: CountsMaxEditField
function CountsMaxEditFieldValueChanged(app, event)
updatePlot(app)
end
% Value changed function: CountsMinEditField
function CountsMinEditFieldValueChanged(app, event)
updatePlot(app)
end
% Value changed function: AltMinEditField
function AltMinEditFieldValueChanged(app, event)
updatePlot(app)
end
% Value changed function: AltMaxEditField
function AltMaxEditFieldValueChanged(app, event)
updatePlot(app)
end
% Button pushed function: StepUpButton
function StepUpButtonPushed(app, event)
app.RecordEditField.Value = app.RecordEditField.Value+1;
app.CurrentRecord = app.RecordEditField.Value;
app.TimeEditField.Value = app.TimeUT(app.CurrentRecord);
updatePlot(app)
end
% Button pushed function: StepDownButton
function StepDownButtonPushed(app, event)
app.RecordEditField.Value = app.RecordEditField.Value-1;
app.CurrentRecord = app.RecordEditField.Value;
app.TimeEditField.Value = app.TimeUT(app.CurrentRecord);
updatePlot(app)
end
% Value changed function: RunButton
function RunButtonValueChanged(app, event)
value = app.RunButton.Value;
while value == 1
app.RunButton.Text = 'Stop';
app.RunButton.BackgroundColor = [1,0,0];
app.RecordEditField.Value = app.RecordEditField.Value+1;
app.CurrentRecord = app.RecordEditField.Value;
app.TimeEditField.Value = app.TimeUT(app.CurrentRecord);
pause(app.DelaysEditField.Value)
updatePlot(app)
value = app.RunButton.Value;
end
app.RunButton.Text = 'Run';
app.RunButton.BackgroundColor = [0.96,0.96,0.96];
end
% Value changed function: Select1064CheckBox
function Select1064CheckBoxValueChanged(app, event)
%uncheck other wavelengths (only one possible)
app.Select532CheckBox.Value = 0;
app.Select355CheckBox.Value = 0;
%set dropdown lists for 1064
app.Channel1DropDown.ValueIndex = 2;
app.Channel2DropDown.ValueIndex = 3;
app.Channel3DropDown.ValueIndex = 1;
app.Channel4DropDown.ValueIndex = 1;
updateData(app);
updatePlot(app)
end
% Value changed function: Select532CheckBox
function Select532CheckBoxValueChanged(app, event)
%uncheck other wavelengths (only one possible)
app.Select1064CheckBox.Value = 0;
app.Select355CheckBox.Value = 0;
%set dropdown lists for 1064
app.Channel1DropDown.ValueIndex = 4;
app.Channel2DropDown.ValueIndex = 5;
app.Channel3DropDown.ValueIndex = 6;
app.Channel4DropDown.ValueIndex = 1;
updateData(app);
updatePlot(app);
end
% Value changed function: Select355CheckBox
function Select355CheckBoxValueChanged(app, event)
%uncheck other wavelengths (only one possible)
app.Select1064CheckBox.Value = 0;
app.Select532CheckBox.Value = 0;
%set dropdown lists for 1064
app.Channel1DropDown.ValueIndex = 7;
app.Channel2DropDown.ValueIndex = 8;
app.Channel3DropDown.ValueIndex = 9;
app.Channel4DropDown.ValueIndex = 10;
updateData(app);
updatePlot(app);
end
% Value changed function: DelaysEditField
function DelaysEditFieldValueChanged(app, event)
value = app.DelaysEditField.Value;
if value < 0.05
app.DelaysEditField.Value = 0.05;
end
end
% Changes arrangement of the app based on UIFigure width
function updateAppLayout(app, event)
currentFigureWidth = app.RawdataPlotterAppUIFigure.Position(3);
if(currentFigureWidth <= app.onePanelWidth)
% Change to a 2x1 grid
app.GridLayout.RowHeight = {642, 642};
app.GridLayout.ColumnWidth = {'1x'};
app.RightPanel.Layout.Row = 2;
app.RightPanel.Layout.Column = 1;
else
% Change to a 1x2 grid
app.GridLayout.RowHeight = {'1x'};
app.GridLayout.ColumnWidth = {220, '1x'};
app.RightPanel.Layout.Row = 1;
app.RightPanel.Layout.Column = 2;
end
end
end
% Component initialization
methods (Access = private)
% Create UIFigure and components
function createComponents(app)
% Create RawdataPlotterAppUIFigure and hide until all components are created
app.RawdataPlotterAppUIFigure = uifigure('Visible', 'off');
app.RawdataPlotterAppUIFigure.AutoResizeChildren = 'off';
app.RawdataPlotterAppUIFigure.Position = [100 100 719 642];
app.RawdataPlotterAppUIFigure.Name = 'Rawdata Plotter App';
app.RawdataPlotterAppUIFigure.CloseRequestFcn = createCallbackFcn(app, @delete(gcf), true); %MARKED
app.RawdataPlotterAppUIFigure.SizeChangedFcn = createCallbackFcn(app, @updateAppLayout, true);
% Create GridLayout
app.GridLayout = uigridlayout(app.RawdataPlotterAppUIFigure);
app.GridLayout.ColumnWidth = {220, '1x'};
app.GridLayout.RowHeight = {'1x'};
app.GridLayout.ColumnSpacing = 0;
app.GridLayout.RowSpacing = 0;
app.GridLayout.Padding = [0 0 0 0];
app.GridLayout.Scrollable = 'on';
% Create LeftPanel
app.LeftPanel = uipanel(app.GridLayout);
app.LeftPanel.Layout.Row = 1;
app.LeftPanel.Layout.Column = 1;
% Create ChannelSelectPanel
app.ChannelSelectPanel = uipanel(app.LeftPanel);
app.ChannelSelectPanel.Title = 'Channel Select';
app.ChannelSelectPanel.Position = [9 132 203 502];
% Create Channel1DropDownLabel
app.Channel1DropDownLabel = uilabel(app.ChannelSelectPanel);
app.Channel1DropDownLabel.HorizontalAlignment = 'right';
app.Channel1DropDownLabel.Position = [19 446 59 22];
app.Channel1DropDownLabel.Text = 'Channel 1';
% Create Channel1DropDown
app.Channel1DropDown = uidropdown(app.ChannelSelectPanel);
app.Channel1DropDown.ValueChangedFcn = createCallbackFcn(app, @Channel1DropDownValueChanged, true);
app.Channel1DropDown.Position = [93 446 100 22];
% Create Channel2DropDownLabel
app.Channel2DropDownLabel = uilabel(app.ChannelSelectPanel);
app.Channel2DropDownLabel.HorizontalAlignment = 'right';
app.Channel2DropDownLabel.Position = [19 412 59 22];
app.Channel2DropDownLabel.Text = 'Channel 2';
% Create Channel2DropDown
app.Channel2DropDown = uidropdown(app.ChannelSelectPanel);
app.Channel2DropDown.ValueChangedFcn = createCallbackFcn(app, @Channel2DropDownValueChanged, true);
app.Channel2DropDown.Position = [93 412 100 22];
% Create Channel3DropDownLabel
app.Channel3DropDownLabel = uilabel(app.ChannelSelectPanel);
app.Channel3DropDownLabel.HorizontalAlignment = 'right';
app.Channel3DropDownLabel.Position = [19 378 59 22];
app.Channel3DropDownLabel.Text = 'Channel 3';
% Create Channel3DropDown
app.Channel3DropDown = uidropdown(app.ChannelSelectPanel);
app.Channel3DropDown.ValueChangedFcn = createCallbackFcn(app, @Channel3DropDownValueChanged, true);
app.Channel3DropDown.Position = [93 378 100 22];
% Create Channel4DropDownLabel
app.Channel4DropDownLabel = uilabel(app.ChannelSelectPanel);
app.Channel4DropDownLabel.HorizontalAlignment = 'right';
app.Channel4DropDownLabel.Position = [19 345 59 22];
app.Channel4DropDownLabel.Text = 'Channel 4';
% Create Channel4DropDown
app.Channel4DropDown = uidropdown(app.ChannelSelectPanel);
app.Channel4DropDown.ValueChangedFcn = createCallbackFcn(app, @Channel4DropDownValueChanged, true);
app.Channel4DropDown.Position = [93 345 100 22];
% Create TimeEditFieldLabel
app.TimeEditFieldLabel = uilabel(app.ChannelSelectPanel);
app.TimeEditFieldLabel.HorizontalAlignment = 'right';
app.TimeEditFieldLabel.Position = [36 210 31 22];
app.TimeEditFieldLabel.Text = 'Time';
% Create TimeEditField
app.TimeEditField = uieditfield(app.ChannelSelectPanel, 'numeric');
app.TimeEditField.ValueDisplayFormat = '%11.6g';
app.TimeEditField.ValueChangedFcn = createCallbackFcn(app, @TimeEditFieldValueChanged, true);
app.TimeEditField.Position = [77 210 100 22];
% Create RecordEditFieldLabel
app.RecordEditFieldLabel = uilabel(app.ChannelSelectPanel);
app.RecordEditFieldLabel.HorizontalAlignment = 'right';
app.RecordEditFieldLabel.Position = [25 185 44 22];
app.RecordEditFieldLabel.Text = 'Record';
% Create RecordEditField
app.RecordEditField = uieditfield(app.ChannelSelectPanel, 'numeric');
app.RecordEditField.ValueChangedFcn = createCallbackFcn(app, @RecordEditFieldValueChanged, true);
app.RecordEditField.Position = [77 185 100 22];
% Create StepUpButton
app.StepUpButton = uibutton(app.ChannelSelectPanel, 'push');
app.StepUpButton.ButtonPushedFcn = createCallbackFcn(app, @StepUpButtonPushed, true);
app.StepUpButton.Position = [109 154 66 23];
app.StepUpButton.Text = 'Step Up';
% Create RunButton
app.RunButton = uibutton(app.ChannelSelectPanel, 'state');
app.RunButton.ValueChangedFcn = createCallbackFcn(app, @RunButtonValueChanged, true);
app.RunButton.Text = 'Run';
app.RunButton.Position = [57 8 60 23];
% Create RangeSquaredCheckBox
app.RangeSquaredCheckBox = uicheckbox(app.ChannelSelectPanel);
app.RangeSquaredCheckBox.Text = 'Range Squared';
app.RangeSquaredCheckBox.Position = [9 82 105 22];
% Create LogScaleCheckBox
app.LogScaleCheckBox = uicheckbox(app.ChannelSelectPanel);
app.LogScaleCheckBox.ValueChangedFcn = createCallbackFcn(app, @LogScaleCheckBoxValueChanged, true);
app.LogScaleCheckBox.Text = 'Log Scale';
app.LogScaleCheckBox.Position = [9 61 76 22];
app.LogScaleCheckBox.Value = true;
% Create LegendCheckBox
app.LegendCheckBox = uicheckbox(app.ChannelSelectPanel);
app.LegendCheckBox.ValueChangedFcn = createCallbackFcn(app, @LegendCheckBoxValueChanged, true);
app.LegendCheckBox.Text = 'Legend';
app.LegendCheckBox.Position = [9 40 62 22];
app.LegendCheckBox.Value = true;
% Create AutoScaleXCheckBox
app.AutoScaleXCheckBox = uicheckbox(app.ChannelSelectPanel);
app.AutoScaleXCheckBox.Text = 'Auto Scale X';
app.AutoScaleXCheckBox.Position = [9 123 91 22];
app.AutoScaleXCheckBox.Value = true;
% Create AutoScaleYCheckBox
app.AutoScaleYCheckBox = uicheckbox(app.ChannelSelectPanel);
app.AutoScaleYCheckBox.Text = 'Auto Scale Y';
app.AutoScaleYCheckBox.Position = [9 103 91 22];
app.AutoScaleYCheckBox.Value = true;
% Create CountsMinEditFieldLabel
app.CountsMinEditFieldLabel = uilabel(app.ChannelSelectPanel);
app.CountsMinEditFieldLabel.HorizontalAlignment = 'right';
app.CountsMinEditFieldLabel.Position = [22 308 67 22];
app.CountsMinEditFieldLabel.Text = 'Counts Min';
% Create CountsMinEditField
app.CountsMinEditField = uieditfield(app.ChannelSelectPanel, 'numeric');
app.CountsMinEditField.ValueChangedFcn = createCallbackFcn(app, @CountsMinEditFieldValueChanged, true);
app.CountsMinEditField.Position = [25 288 66 22];
app.CountsMinEditField.Value = 0.1;
% Create CountsMaxEditFieldLabel
app.CountsMaxEditFieldLabel = uilabel(app.ChannelSelectPanel);
app.CountsMaxEditFieldLabel.HorizontalAlignment = 'right';
app.CountsMaxEditFieldLabel.Position = [104 308 70 22];
app.CountsMaxEditFieldLabel.Text = 'Counts Max';
% Create CountsMaxEditField
app.CountsMaxEditField = uieditfield(app.ChannelSelectPanel, 'numeric');
app.CountsMaxEditField.ValueChangedFcn = createCallbackFcn(app, @CountsMaxEditFieldValueChanged, true);
app.CountsMaxEditField.Position = [104 288 70 22];
app.CountsMaxEditField.Value = 65536;
% Create AltMinEditFieldLabel
app.AltMinEditFieldLabel = uilabel(app.ChannelSelectPanel);
app.AltMinEditFieldLabel.HorizontalAlignment = 'right';
app.AltMinEditFieldLabel.Position = [36 267 42 22];
app.AltMinEditFieldLabel.Text = 'Alt Min';
% Create AltMinEditField
app.AltMinEditField = uieditfield(app.ChannelSelectPanel, 'numeric');
app.AltMinEditField.ValueChangedFcn = createCallbackFcn(app, @AltMinEditFieldValueChanged, true);
app.AltMinEditField.Position = [25 246 66 22];
app.AltMinEditField.Value = -500;
% Create AltMaxEditFieldLabel
app.AltMaxEditFieldLabel = uilabel(app.ChannelSelectPanel);
app.AltMaxEditFieldLabel.HorizontalAlignment = 'right';
app.AltMaxEditFieldLabel.Position = [114 267 46 22];
app.AltMaxEditFieldLabel.Text = 'Alt Max';
% Create AltMaxEditField
app.AltMaxEditField = uieditfield(app.ChannelSelectPanel, 'numeric');
app.AltMaxEditField.ValueChangedFcn = createCallbackFcn(app, @AltMaxEditFieldValueChanged, true);
app.AltMaxEditField.Position = [104 246 69 22];
app.AltMaxEditField.Value = 22000;
% Create StepDownButton
app.StepDownButton = uibutton(app.ChannelSelectPanel, 'push');
app.StepDownButton.ButtonPushedFcn = createCallbackFcn(app, @StepDownButtonPushed, true);
app.StepDownButton.Position = [24 154 75 23];
app.StepDownButton.Text = 'Step Down';
% Create DelaysEditFieldLabel
app.DelaysEditFieldLabel = uilabel(app.ChannelSelectPanel);
app.DelaysEditFieldLabel.HorizontalAlignment = 'right';
app.DelaysEditFieldLabel.Position = [119 34 51 22];
app.DelaysEditFieldLabel.Text = 'Delay (s)';
% Create DelaysEditField
app.DelaysEditField = uieditfield(app.ChannelSelectPanel, 'numeric');
app.DelaysEditField.ValueChangedFcn = createCallbackFcn(app, @DelaysEditFieldValueChanged, true);
app.DelaysEditField.Position = [128 9 34 22];
app.DelaysEditField.Value = 1;
% Create Select1064CheckBox
app.Select1064CheckBox = uicheckbox(app.ChannelSelectPanel);
app.Select1064CheckBox.ValueChangedFcn = createCallbackFcn(app, @Select1064CheckBoxValueChanged, true);
app.Select1064CheckBox.Text = 'Select 1064';
app.Select1064CheckBox.Position = [119 124 86 22];
% Create Select532CheckBox
app.Select532CheckBox = uicheckbox(app.ChannelSelectPanel);
app.Select532CheckBox.ValueChangedFcn = createCallbackFcn(app, @Select532CheckBoxValueChanged, true);
app.Select532CheckBox.Text = 'Select 532';
app.Select532CheckBox.Position = [119 101 79 22];
% Create Select355CheckBox
app.Select355CheckBox = uicheckbox(app.ChannelSelectPanel);
app.Select355CheckBox.ValueChangedFcn = createCallbackFcn(app, @Select355CheckBoxValueChanged, true);
app.Select355CheckBox.Text = 'Select 355';
app.Select355CheckBox.Position = [119 79 79 22];
% Create ControlPanel
app.ControlPanel = uipanel(app.LeftPanel);
app.ControlPanel.Title = 'Control';
app.ControlPanel.Position = [9 13 203 110];
% Create QuitButton
app.QuitButton = uibutton(app.ControlPanel, 'push');
app.QuitButton.ButtonPushedFcn = createCallbackFcn(app, @QuitButtonPushed, true);
app.QuitButton.FontWeight = 'bold';
app.QuitButton.FontColor = [1 0 0];
app.QuitButton.Position = [57 12 100 23];
app.QuitButton.Text = 'Quit';
% Create SelectDataFileButton
app.SelectDataFileButton = uibutton(app.ControlPanel, 'push');
app.SelectDataFileButton.ButtonPushedFcn = createCallbackFcn(app, @SelectDataFileButtonPushed, true);
app.SelectDataFileButton.Position = [57 54 100 23];
app.SelectDataFileButton.Text = 'Select Data File';
% Create RightPanel
app.RightPanel = uipanel(app.GridLayout);
app.RightPanel.Layout.Row = 1;
app.RightPanel.Layout.Column = 2;
% Create Panel3
app.Panel3 = uipanel(app.RightPanel);
app.Panel3.Title = 'Panel3';
app.Panel3.Position = [9 142 481 493];
% Create UIAxes
app.UIAxes = uiaxes(app.Panel3);
xlabel(app.UIAxes, 'Counts')
ylabel(app.UIAxes, 'Altitude (km)')
zlabel(app.UIAxes, 'Z')
app.UIAxes.GridLineWidth = 0.5;
app.UIAxes.MinorGridLineWidth = 0.5;
app.UIAxes.LineWidth = 0.5;
app.UIAxes.Box = 'off';
app.UIAxes.FontSize = 14;
app.UIAxes.Position = [4 0 475 469];
% Create Panel4
app.Panel4 = uipanel(app.RightPanel);
app.Panel4.Title = 'Panel4';
app.Panel4.Position = [9 10 479 123];
% Create FilenameEditFieldLabel
app.FilenameEditFieldLabel = uilabel(app.Panel4);
app.FilenameEditFieldLabel.HorizontalAlignment = 'right';
app.FilenameEditFieldLabel.Position = [14 75 53 22];
app.FilenameEditFieldLabel.Text = 'Filename';
% Create FilenameEditField
app.FilenameEditField = uieditfield(app.Panel4, 'text');
app.FilenameEditField.Position = [82 75 388 22];
% Create PathnameEditFieldLabel
app.PathnameEditFieldLabel = uilabel(app.Panel4);
app.PathnameEditFieldLabel.HorizontalAlignment = 'right';
app.PathnameEditFieldLabel.Position = [8 47 59 22];
app.PathnameEditFieldLabel.Text = 'Pathname';
% Create PathnameEditField
app.PathnameEditField = uieditfield(app.Panel4, 'text');
app.PathnameEditField.Position = [82 47 388 22];
% Create StatusEditFieldLabel
app.StatusEditFieldLabel = uilabel(app.Panel4);
app.StatusEditFieldLabel.HorizontalAlignment = 'right';
app.StatusEditFieldLabel.Position = [28 19 39 22];
app.StatusEditFieldLabel.Text = 'Status';
% Create StatusEditField
app.StatusEditField = uieditfield(app.Panel4, 'text');
app.StatusEditField.Position = [82 19 388 22];
% Show the figure after all components are created
app.RawdataPlotterAppUIFigure.Visible = 'on';
end
end
% App creation and deletion
methods (Access = public)
% Construct app
function app = RawDataPlotterNew
% Create UIFigure and components
createComponents(app)
% Register the app with App Designer
registerApp(app, app.RawdataPlotterAppUIFigure)
% Execute the startup function
runStartupFcn(app, @startupFcn)
if nargout == 0
clear app
end
end
% Code that executes before app deletion
function delete(app)
% Delete UIFigure when app is deleted
delete(app.RawdataPlotterAppUIFigure)
end
end
end
回答(1 个)
Rik
2024-9-8
In this case the syntax error is because the anonymous function is incorrect:
app.RawdataPlotterAppUIFigure.CloseRequestFcn = createCallbackFcn(app, @delete(gcf), true);
That should probably be:
@() delete(gcf)
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!