Working with objects from other classes within MATLAB app editor
Show older comments
Hello,
I am just getting started simultaneosly with OOP and app editor and I have an issue handling with data objects defined under another class (separete class definition in a .m file). This is the class definition I use to arrange the raw data, it is pretty simple:
classdef Land < handle
properties ( Access = ?GlobalCovidData)
Name
Main
CovidCases
DeathCases
Regions
end
%include methods to set the Names as strings of the corresponding cells
end
As you see, the properties of the class are open to GlobalCovidData, which is my app. the Now, within the app editor I wrote a huge code to arrange the data in objects under the class Land. This code is writen within the function startupFcn(app) and allows to draw the data and plot them. Within the startupFcn(app) there are several definitions of data objects for the class Land. These are just random code lines to show that:
%when drawing data from the given file
world = Land; world.Name="Global";
countries{count} = Land; countries{count}.Name=string(A{i,1}); countries{count}.Main = world;
divisions{i-count-1} = Land;
% these ojects are basically covid19 incidence data of all countries
for k=2:length(countries)
% add next country to world cases
world.CovidCases = world.CovidCases + countries(k).CovidCases;
world.DeathCases = world.DeathCases + countries(k).DeathCases;
end
%when creating arrays to plot, that already worked
app.Positives = world.CovidCases;
app.Deaths = world.DeathCases;
Now when I try to use the same objects from callback function of a widget, I get an error upon running the app:

Note that countries and world had alread worked within the startupFcn(app) or its methods. I already defined the Land class as property of the app class. I think I can try writing the function to handle with this objects withing the app methods, but then I don't understand much what are the callback functions for. Are they only as event triggering, that means, to call class (app) properties?
Thanks in advance for any clue.
BR,
Carlos.
Accepted Answer
More Answers (0)
Categories
Find more on Workspace Variables and MAT Files in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!