MATLAB Answers

Using +package folders with appdesigner apps

15 views (last 30 days)
Kiran Ramsaroop
Kiran Ramsaroop on 6 Mar 2020
Edited: J. Alex Lee on 6 Mar 2020
Hi all
I am trying to partition methods from an appdesigner App into different files, in turn, by folder. To me, it makes sense to segment into packages using the "+" notation, within the Class folder for the app, denoted by @AnalysisApp.
-- + get
-- + generate
-- + do
etc, with each method within the +get, +generate, etc folders accessible using the dot notation, i.e. "". However, this doesn't seem to work as each method is not defined as being a method of the AnalysisApp class. When I explicitly define a static private method in the top level .mlapp code, this still doesn't seem to work.
I have also tried making the package folders class folders, and defining a subclass to inherit from the top level AnalysisApp class, which in turn inherits from the matlab base appdesigner class, as defined in the AnalysisApp.mlapp file, but this doesn't work either.
For now, i have settled with non-private and non-package subfolders, so simply:
-- get
-- generate,
etc as subfolders to @AnalysisApp.
That seems to work, but obviously I can't use the dot notation, so organising my code is not as straightforward and I may end up with shadowed files, for example if i wish to have a get.DataItem and generate.Dataitem; the whole reason i wished to use the package notation! Additionally, I now get an error talking about "Method Directories"; "Method directories not allowed in MATLAB path: ...\@AnalysisApp". I'm guessing I am not allowed to have directories containing methods as subfolders of an appdesigner app class?
Help! And thanks in advance :)

  1 Comment

J. Alex Lee
J. Alex Lee on 6 Mar 2020
I wouldn't try to use "." in the way you are, especially "get.PROPERTY" is the syntax to define a get method.
Can you make "DataItem" into a class, endowed with its own methods, so you can instead do things like
app.DataItemInstance = DataItem(); % create a DataItem instance
app.DataItemInstance.getdata % would replace your desired "get.DataItem"
app.DataItemInstance.generate % would replace your desired "generate.DataItem"
classdef DataItem
function this = DataItem()
function generate(this,varargin)
function getdata(this,varargin)

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by