Being able to store multiple user selected values from a tree, MATLAB APP Designer
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello everyone! I have been trying for the last couple hours to figure out how to store the values a user would select from a tree, while also being able to pickup when the user deselects a previously selected node. I havent found much insight or previous questions on how this might be accomplished.
For instance,
If the user selects the above two options, I notice that in the app.Tree.CheckedNodes it stores a 2x1 TreeNode array with the values I need to "detect" embded within. How would I be able to scan for the user selcted data?? Bellow is the mentioned function.
function TreeCheckedNodesChanged(app, event)
checkedNodes.Text = app.Tree.CheckedNodes;
Selc = checkedNodes.Text
if contains(Selc,"3D Yield Surface")
app.Checked(1) = [1];
else
app.Checked(1) = 0;
end
if contains(Selc,'Yield Strength vs Orientation')
app.Checked(2) = [1];
else
app.Checked(2) = 0;
end
if contains(Selc,'Actual vs Predicted')
app.Checked(3) = [1];
else
app.Checked(3) = 0;
end
app.UITable.ColumnName = {app.Checked};
That app.Checked bit is just so I could check if my code was working in real time, all it is supposed to do is store if the user made the change, please let me know if you see any better way to accomplish this aswell.
Thank you again and again!
Kevin
1 Kommentar
Antworten (1)
Dinesh
am 15 Nov. 2023
Hi Kevin.
You can use "Properties" to store the data in your app. The following link will help you:
https://www.mathworks.com/help/matlab/creating_guis/share-data-across-callbacks-in-app-designer.html
Once a property is defined, identify parts in your code where you would like the variable's data to be stored. Now assign the appropriate property's value to the state variable.
In your case, when the callback function is called when the checkbox is checked or unchecked, you can programmatically find out which checkbox is checked or unchecked after which the property variables can be changed. These properties that are stored can be accessed by other functions and callbacks to perform operations.
0 Kommentare
Siehe auch
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!