I would like to know how would I load a structured variable from a matfile into AppDesigner?

9 Ansichten (letzte 30 Tage)
function LoadButtonPushed(app, event)
loadedPdp = load("C:\Users\HelloWorld\Desktop\AppDesigner\Draft 8\matlab.mat",'pdp'); %change the directory accordingly
app.loadedData = loadedPdp.pdp; %Assign loaded data to 'app.loadedData'
The structure I am trying to load is pdp.

Akzeptierte Antwort

Ayush
Ayush am 29 Aug. 2023
Hey Suhas,
I understand that you want to load a structured variable into App Designer and the structure is pdp.
You can follow these steps for the same:
  1. Start by opening your App Designer project.
  2. In App Designer, go to the "Code View" tab. You can find it in the upper-right corner of the App Designer window.
  3. Inside the "Code View" tab, locate the “startupFcn” function. This function is executed when the app starts.
  4. Within the “startupFcn” function, you can use the following code to load the structured variable from the MAT file.
% Load the MAT file
data = load('fileName.mat');
% Access the structured variable (pdp in this case)
pdp = data.pdp;
This will help you access the pdp variable within your App Designer project.
For more information, you can refer the documentation for App Designer: Develop Apps Using App Designer - MATLAB & Simulink - MathWorks India
Hope this helps!!
  1 Kommentar
Suhas Ramanan
Suhas Ramanan am 29 Aug. 2023
Hi Ayush,
Thanks for your answer! I also realised we need to include it in the properties like this. But yes, you're right!
properties (Access = private)
% Property to store loaded double variable VERY IMPORTANT else it will not be recognised as a class in this app
loadedData struct

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Develop Apps Using App Designer finden Sie in Help Center und File Exchange

Produkte


Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by