필터 지우기
필터 지우기

load multiple .mat files

조회 수: 1 (최근 30일)
neamah al-naffakh
neamah al-naffakh 2016년 12월 28일
편집: neamah al-naffakh 2016년 12월 30일
hi everyone,
I have a question.
I am analysing some data which have multiple subjects. Information about every subject is stored in the MATLAB structure (.mat file)
For Example:
U1_Acc_TimeD_FreqD_FDay.mat
U2_Acc_TimeD_FreqD_FDay.mat
U1_Acc_TimeD_FreqD_FDay.mat
and so on...
I would like to create for loop which in every iteration load new data_number.mat file.
I'd like in every iteration to load next .mat file? Particularly, I don't know how to address number part of filename using load function.
I tried this code and seems it's overwritten the data!
clear;
for nc = 1:36
load(['U', num2str(nc,'%2d'), '_Acc_TimeD_FreqD_FDay.mat']);
end
Thank you

채택된 답변

Walter Roberson
Walter Roberson 2016년 12월 28일
load(['U_', num2str(nc,'%02d'), 'Acc_TimeD_FreqD_FDay.mat']);
or
load( sprintf('U_%02dAcc_TimeD_FreqD_FDay.mat', nc) );
  댓글 수: 10
Walter Roberson
Walter Roberson 2016년 12월 28일
Notice I had suggested
for j = 1 : size(data,2)
rather than
for j = size(data,2)
the second of those does only size(data,2)
neamah al-naffakh
neamah al-naffakh 2016년 12월 30일
편집: neamah al-naffakh 2016년 12월 30일
dear Walter Roberson, many thanks for your help. I really appreciate it.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by