Automatically loading the .mat file

조회 수: 9 (최근 30일)
Prasad Joshi
Prasad Joshi . 2022년 2월 1일
댓글: Prasad Joshi . 2022년 2월 9일
I am working on following code .In the code I am manually loading the matlab file .But know the cases are increases to 27 mat files. can someone help me in automating the process means automatically loading the matlab file from a specific folder and then storing in the excel file .Can someone please help me this . Thank you in advance . Automatically loading means loading the file from the specific folder . without manually loading . For eg in folder ABC I have mat file AAA.mat , BBB.mat , CCC.mat ...So first AAA.mat should load then store the data in excel file (the code that I used) , then BBB.mat & so on ... Thanks in advance
n = numel(filenames) ;
A = zeros([],n) ;
for i = 1:numel(filenames)
CO= CO_sim_mass_cum;
nmHC= nmHC_sim_mass_cum;
for j = 1:length(CO)
A(j,i) = THC(j);
for k= 1:length(NOx)
for l= 1:length(nmHC)

채택된 답변

Walter Roberson
Walter Roberson 2022년 2월 2일
dinfo = dir('*.mat');
filenames = {};
  댓글 수: 3
Prasad Joshi
Prasad Joshi 2022년 2월 9일

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

추가 답변 (1개)

Yongjian Feng
Yongjian Feng 2022년 2월 1일
For "automatically loading", you most likely mean generating the file names in a loop?
Try this:
num_case = 26;
for i=1:num_case
filename = ['C1_H1_C2_case' num2str(i) '_WLTC_']; % something else at the end? Not shown in the attached screenshot
files{end+1} = filename;
  댓글 수: 7
Prasad Joshi
Prasad Joshi 2022년 2월 9일
yongjian san can you answer the below question thank you in advance .. it would be higly helpful

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


Help CenterFile Exchange에서 MATLAB Report Generator에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by