I need load data .mat from file to my workspace. I used this code: filename = uigetfile({'*.mat'}, 'Select mat file'); but it´s non-functional. I need load data .mat to workspace and save to value with name x1. Is here somebody who know help? T
조회 수: 10 (최근 30일)
이전 댓글 표시
I need load data .mat from file to my workspace. I used this code: filename = uigetfile({'*.mat'}, 'Select mat file'); but it´s non-functional. I need load data .mat to workspace and save to value with name x1. Is here somebody who know help? T
댓글 수: 0
채택된 답변
Walter Roberson
2016년 10월 31일
temp = load('z1.mat');
fn = fieldnames(temp);
x1 = temp.(fn{1});
This will load the "first" variable stored in the .mat file into the variable "x1".
댓글 수: 3
Walter Roberson
2016년 10월 31일
[filename, foldername] = uigetfile('*.mat', 'Select a mat file');
fullname = fullfile(foldername, filename);
temp = load(fullname);
fn = fieldnames(temp);
x1 = temp.(fn{1});
추가 답변 (2개)
Alexandra Harkai
2016년 10월 31일
If you know your file will be named data.mat, you don't need uigetfile, simply load will do that for you:
x1 = load('data.mat')
참고 항목
카테고리
Help Center 및 File Exchange에서 Workspace Variables and MAT-Files에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!