Compiled version fails when highpass is called “Error using toolboxdir. Could not locate the base directory for dsp/filterdesign’.
I have created an App in App Designer which works fine until I compile. Everything still works as expected, except the functionality that uses the ‘highpass’ function from the Signal Processing toolbox. The log file states:
"Error using toolboxdir (line 54)
Could not locate the base directory for dsp/filterdesign.
I have checked that the toolbox is installed (I even reinstalled it again) and checked the path to the toolbox exists using toolboxdir(‘signal’).
I created a small test app that recreates the problem.The test app simply creates 100 random numbers, plots them and then applies the highpass filter on the click of a button. Again, the application fails once it is compiled.
I read that the Matlab compiler should detect and automatically include any toolbox requirements. I even tried forcing this detection by adding some non-consequential calls to highpass.m . The code for the test application is below.
Can anybody suggest what I am doing wrong?
classdef testHighPass < matlab.apps.AppBase
% Properties that correspond to app components
properties (Access = public)
UIFigure matlab.ui.Figure
FilterButton matlab.ui.control.Button
GenerateDataButton matlab.ui.control.Button
plotAxes matlab.ui.control.UIAxes
end
properties (Access = private)
data % Description
x
end
% Callbacks that handle component events
methods (Access = private)
% Button pushed function: GenerateDataButton
function GenerateDataButtonPushed(app, event)
app.data = rand(1, 100);
app.x = 1:100;
hold(app.plotAxes, ‘off’);
plot(app.plotAxes, app.x, app.data);
hold(app.plotAxes,’on’)
end
% Button pushed function: FilterButton
function FilterButtonPushed(app, event)
filt_data = highpass(app.data, 0.8);
plot(app.plotAxes, app.x, filt_data, ‘r’);
end
end
% Component initialization
methods (Access = private)
% Create UIFigure and components
function createComponents(app)
% Create UIFigure and hide until all components are created
app.UIFigure = uifigure(‘Visible’, ‘off’);
app.UIFigure.Position = [100 100 640 480];
app.UIFigure.Name = ‘MATLAB App’;
% Create plotAxes
app.plotAxes = uiaxes(app.UIFigure);
title(app.plotAxes, ‘Data’)
xlabel(app.plotAxes, ‘X’)
ylabel(app.plotAxes, ‘Y’)
zlabel(app.plotAxes, ‘Z’)
app.plotAxes.Position = [101 161 446 280];
% Create GenerateDataButton
app.GenerateDataButton = uibutton(app.UIFigure, ‘push’);
app.GenerateDataButton.ButtonPushedFcn = createCallbackFcn(app, @GenerateDataButtonPushed, true);
app.GenerateDataButton.Position = [74 95 122 37];
app.GenerateDataButton.Text = ‘Generate Data’;
% Create FilterButton
app.FilterButton = uibutton(app.UIFigure, ‘push’);
app.FilterButton.ButtonPushedFcn = createCallbackFcn(app, @FilterButtonPushed, true);
app.FilterButton.Position = [399 96 130 35];
app.FilterButton.Text = ‘Filter’;
% Show the figure after all components are created
app.UIFigure.Visible = ‘on’;
end
end
% App creation and deletion
methods (Access = public)
% Construct app
function app = testHighPass
% Create UIFigure and components
createComponents(app)
% Register the app with App Designer
registerApp(app, app.UIFigure)
if nargout == 0
clear app
end
end
% Code that executes before app deletion
function delete(app)
% Delete UIFigure when app is deleted
delete(app.UIFigure)
end
end
endI have created an App in App Designer which works fine until I compile. Everything still works as expected, except the functionality that uses the ‘highpass’ function from the Signal Processing toolbox. The log file states:
"Error using toolboxdir (line 54)
Could not locate the base directory for dsp/filterdesign.
I have checked that the toolbox is installed (I even reinstalled it again) and checked the path to the toolbox exists using toolboxdir(‘signal’).
I created a small test app that recreates the problem.The test app simply creates 100 random numbers, plots them and then applies the highpass filter on the click of a button. Again, the application fails once it is compiled.
I read that the Matlab compiler should detect and automatically include any toolbox requirements. I even tried forcing this detection by adding some non-consequential calls to highpass.m . The code for the test application is below.
Can anybody suggest what I am doing wrong?
classdef testHighPass < matlab.apps.AppBase
% Properties that correspond to app components
properties (Access = public)
UIFigure matlab.ui.Figure
FilterButton matlab.ui.control.Button
GenerateDataButton matlab.ui.control.Button
plotAxes matlab.ui.control.UIAxes
end
properties (Access = private)
data % Description
x
end
% Callbacks that handle component events
methods (Access = private)
% Button pushed function: GenerateDataButton
function GenerateDataButtonPushed(app, event)
app.data = rand(1, 100);
app.x = 1:100;
hold(app.plotAxes, ‘off’);
plot(app.plotAxes, app.x, app.data);
hold(app.plotAxes,’on’)
end
% Button pushed function: FilterButton
function FilterButtonPushed(app, event)
filt_data = highpass(app.data, 0.8);
plot(app.plotAxes, app.x, filt_data, ‘r’);
end
end
% Component initialization
methods (Access = private)
% Create UIFigure and components
function createComponents(app)
% Create UIFigure and hide until all components are created
app.UIFigure = uifigure(‘Visible’, ‘off’);
app.UIFigure.Position = [100 100 640 480];
app.UIFigure.Name = ‘MATLAB App’;
% Create plotAxes
app.plotAxes = uiaxes(app.UIFigure);
title(app.plotAxes, ‘Data’)
xlabel(app.plotAxes, ‘X’)
ylabel(app.plotAxes, ‘Y’)
zlabel(app.plotAxes, ‘Z’)
app.plotAxes.Position = [101 161 446 280];
% Create GenerateDataButton
app.GenerateDataButton = uibutton(app.UIFigure, ‘push’);
app.GenerateDataButton.ButtonPushedFcn = createCallbackFcn(app, @GenerateDataButtonPushed, true);
app.GenerateDataButton.Position = [74 95 122 37];
app.GenerateDataButton.Text = ‘Generate Data’;
% Create FilterButton
app.FilterButton = uibutton(app.UIFigure, ‘push’);
app.FilterButton.ButtonPushedFcn = createCallbackFcn(app, @FilterButtonPushed, true);
app.FilterButton.Position = [399 96 130 35];
app.FilterButton.Text = ‘Filter’;
% Show the figure after all components are created
app.UIFigure.Visible = ‘on’;
end
end
% App creation and deletion
methods (Access = public)
% Construct app
function app = testHighPass
% Create UIFigure and components
createComponents(app)
% Register the app with App Designer
registerApp(app, app.UIFigure)
if nargout == 0
clear app
end
end
% Code that executes before app deletion
function delete(app)
% Delete UIFigure when app is deleted
delete(app.UIFigure)
end
end
end I have created an App in App Designer which works fine until I compile. Everything still works as expected, except the functionality that uses the ‘highpass’ function from the Signal Processing toolbox. The log file states:
"Error using toolboxdir (line 54)
Could not locate the base directory for dsp/filterdesign.
I have checked that the toolbox is installed (I even reinstalled it again) and checked the path to the toolbox exists using toolboxdir(‘signal’).
I created a small test app that recreates the problem.The test app simply creates 100 random numbers, plots them and then applies the highpass filter on the click of a button. Again, the application fails once it is compiled.
I read that the Matlab compiler should detect and automatically include any toolbox requirements. I even tried forcing this detection by adding some non-consequential calls to highpass.m . The code for the test application is below.
Can anybody suggest what I am doing wrong?
classdef testHighPass < matlab.apps.AppBase
% Properties that correspond to app components
properties (Access = public)
UIFigure matlab.ui.Figure
FilterButton matlab.ui.control.Button
GenerateDataButton matlab.ui.control.Button
plotAxes matlab.ui.control.UIAxes
end
properties (Access = private)
data % Description
x
end
% Callbacks that handle component events
methods (Access = private)
% Button pushed function: GenerateDataButton
function GenerateDataButtonPushed(app, event)
app.data = rand(1, 100);
app.x = 1:100;
hold(app.plotAxes, ‘off’);
plot(app.plotAxes, app.x, app.data);
hold(app.plotAxes,’on’)
end
% Button pushed function: FilterButton
function FilterButtonPushed(app, event)
filt_data = highpass(app.data, 0.8);
plot(app.plotAxes, app.x, filt_data, ‘r’);
end
end
% Component initialization
methods (Access = private)
% Create UIFigure and components
function createComponents(app)
% Create UIFigure and hide until all components are created
app.UIFigure = uifigure(‘Visible’, ‘off’);
app.UIFigure.Position = [100 100 640 480];
app.UIFigure.Name = ‘MATLAB App’;
% Create plotAxes
app.plotAxes = uiaxes(app.UIFigure);
title(app.plotAxes, ‘Data’)
xlabel(app.plotAxes, ‘X’)
ylabel(app.plotAxes, ‘Y’)
zlabel(app.plotAxes, ‘Z’)
app.plotAxes.Position = [101 161 446 280];
% Create GenerateDataButton
app.GenerateDataButton = uibutton(app.UIFigure, ‘push’);
app.GenerateDataButton.ButtonPushedFcn = createCallbackFcn(app, @GenerateDataButtonPushed, true);
app.GenerateDataButton.Position = [74 95 122 37];
app.GenerateDataButton.Text = ‘Generate Data’;
% Create FilterButton
app.FilterButton = uibutton(app.UIFigure, ‘push’);
app.FilterButton.ButtonPushedFcn = createCallbackFcn(app, @FilterButtonPushed, true);
app.FilterButton.Position = [399 96 130 35];
app.FilterButton.Text = ‘Filter’;
% Show the figure after all components are created
app.UIFigure.Visible = ‘on’;
end
end
% App creation and deletion
methods (Access = public)
% Construct app
function app = testHighPass
% Create UIFigure and components
createComponents(app)
% Register the app with App Designer
registerApp(app, app.UIFigure)
if nargout == 0
clear app
end
end
% Code that executes before app deletion
function delete(app)
% Delete UIFigure when app is deleted
delete(app.UIFigure)
end
end
end runtime error, toolboxdir, base directory MATLAB Answers — New Questions