MATLAB Answers

How can I select a specific variable in the .mat file which contains different variables in the user interface?

2 views (last 30 days)
Hi! I want to design an app which can draw with a .mat file. How can I select a specific variable in the .mat file which contains different variables in the user interface? By 'text area' or something?

  0 Comments

Sign in to comment.

Accepted Answer

Fangjun Jiang
Fangjun Jiang on 5 Dec 2019
  1. Use load() with return structure.
gongStruct = load('gong.mat');
fieldnames(gongStruct)
  1. Use matfile object.
Help matfile

  0 Comments

Sign in to comment.

More Answers (1)

Cam Salzberger
Cam Salzberger on 5 Dec 2019
Edited: Cam Salzberger on 5 Dec 2019
Hello Kunpeng,
You may consider using whos to determine the variables available in a MAT file. Then you can specify the variable you want when you call load based on the user selection. This will be faster than loading the entire MAT file into the workspace, unless you expect the user to frequently switch between what they want loaded.
You may also consider checking out the matfile object, as Fangjun suggested.
-Cam

Sign in to answer this question.