필터 지우기
필터 지우기

Using for loop to load multiple mat files of same names

조회 수: 9 (최근 30일)
Abdulhakim Alezzi
Abdulhakim Alezzi 2020년 4월 19일
댓글: Abdulhakim Alezzi 2020년 4월 19일
Hi everyone,
can amyone please help on the following :
I have a folder contains mualiple matfiles C1,C2,C3,C4.....C20.
1- I want to load all these files using for loop . All the files has the same matrix name (data) .. Then i want to claculate the absolute FFT for every single subject as follow:
Y= abs(fft(data));
2- i want to save the result of file 1 with Y1, and file 2 with Y2 and so on till C20 named with Y20.
is there any way I can do it?
Any help will be highly apperciated .
  댓글 수: 2
Abdulhakim Alezzi
Abdulhakim Alezzi 2020년 4월 19일
Dear Mr. Kalyan,
i have tried this code but it does not work for me .
path_directory='folder_name'; % 'Folder name'
original_files=dir([path_directory '/*.mat']);
for k=1:length(original_files)
filename=[path_directory '/' original_files(k).name];
image_orginal=imread(filename);
end

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

채택된 답변

Stephen23
Stephen23 2020년 4월 19일
Try something like this:
N = 20;
D = 'path to the folder where the files are saved';
for k = 1:N
F = fullfile(D,sprintf('C%d.mat',k));
S = load(F);
Y = abs(fft(S.data));
F = fullfile(D,sprintf('Y%d.mat',k));
save(F,'Y')
end
  댓글 수: 1
Abdulhakim Alezzi
Abdulhakim Alezzi 2020년 4월 19일
Dear respected Stephen,
This is working perefectly. Thank you very much.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Adding custom doc에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by