如何用appdesi​gner读取mat文​件显示所有变量

15 ビュー (過去 30 日間)
爱玲 袁
爱玲 袁 2022 年 10 月 27 日
回答済み: Praveen Reddy 2023 年 6 月 26 日
我想设计一个界面处理数据,首先我想要去读mat文件并且显示所有的变量,然后依次对变量进行处理,那么应该如何在appdesigner上面读取mat文件并且显示变量呢?

回答 (1 件)

Praveen Reddy
Praveen Reddy 2023 年 6 月 26 日
I understand that you want to read variables from a ‘.mat’ file and display the variables on app designer.
  • In the App Desginer add a button to trigger the file selection process
  • Add a call back function to the button.
  • Inside the callaback function you can use ‘uigetfile’ function to read ‘.mat’ file
  • Extract the variables using ‘getfieldnames’ function.
  • Use a uicomponent like ‘uitable’to display the variables read.
function ButtonPushed(app, event)
[filename, pathname] = uigetfile('*.mat', 'Select the MAT file');
matfile = fullfile(pathname, filename);
data=load(matfile);
variables = fieldnames(data);
app.ListBox.Items = variables;
end
Please refer the attached ‘.malpp ‘ file.
To know more about ‘uigetfile’, ‘fieldnames’ functions, refer the following MATLAB documentations

カテゴリ

Help Center および File Exchange使用 App 设计工具开发 App についてさらに検索

Community Treasure Hunt

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

Start Hunting!