A question about the declaration of public properties in apps
20 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi! :)
I have a question: if I have declared a property as a public variable in my main app, is it necessary that I also declare it as a private property in the app I am using it.
In my case I have a table Osmotisk_data that I have declared as a public property in the main app, then I am using some of the columns (arrays) from this table in another app, there I have declared it as a private property, but I am a little confused becuase I am not getting the results that I am supposed to get.
0 Kommentare
Antworten (1)
Steven Lord
am 12 Okt. 2024 um 15:46
How are you planning to share the data between the two apps? This documentation page offers some guidance on how to do that.
2 Kommentare
Steven Lord
am 12 Okt. 2024 um 16:42
Anyone with access to the app object has access to its public properties. But are you giving that second app access to that first app object?
As a non-app example, I'll create a variable R. Don't worry too much about the details of what it is. What's important is that it's an object.
R = RandStream.create('mt19937ar');
It has properties that I can get since I have access to the object.
p = properties(R)
S = R.Seed
But if I call a function and don't give it the object, it can't ask for properties of the object even though they're public. It has no idea what R is, even though it exists in the calling workspace. It didn't get passed into the myfun workspace.
myfun() % will error, doesn't know what R is
function myfun
disp("Inside function myfun, trying to get the Seed property from R")
y = R.Seed; % will error
end
That documentation page I linked to gives some guidance about how to make the first app object accessible to the second app.
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!