Loading data from UIAxes to the appdesigner code

1 view (last 30 days)
I am trying to create an appdesigner. Firstly, one can select the .mat file from computer by pushing a button. The selected Figure is shown on UIAxes. Secondly, I want to use data of the selected .mat file when the second button is pushed.
I did the first part, but I could not load the .mat file in the second part of the code.
I wrote the following in the first part:
function SquareButtonPushed(app, event)
load('squareImage.mat')
M = squareImage;
imagesc(app.Ax1,squareImage)
end
For the second part:
function BackProjectionButtonPushed(app, event)
load('app.Ax1')
M = app.Ax1;
However,
Error using load
Unable to read file 'app.Ax1'. No such file or directory.
How can I load the data of app.Ax1 to M?

Answers (1)

Cris LaPierre
Cris LaPierre on 26 Dec 2019
Edited: Cris LaPierre on 26 Dec 2019
app.Ax1 is a handle to the figure, not a mat file that can be loaded.
If you know what variables exist in the mat file, you can add them as properties to the app, making them available via the app structure.
For example, create a property M, and in the first function, modify the code to be
app.M = squareImage;
Then in the second function because you are already passing in app as an input, you can access the variable using dot notation: app.M

Categories

Find more on Develop Apps Using App Designer in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!