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

9 visualizzazioni (ultimi 30 giorni)
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?

Risposta accettata

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

Più risposte (1)

Cam Salzberger
Cam Salzberger il 5 Dic 2019
Modificato: Cam Salzberger il 5 Dic 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
  5 Commenti
Kunpeng Zhang
Kunpeng Zhang il 14 Mar 2020
Wow,that is awesome!!!I will study and try alternative methods. Thank you for your advice!!

Accedi per commentare.

Categorie

Scopri di più su Workspace Variables and MAT Files in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by