i have a list of engine data files and im supposed to automate the process of decoding them and finding the average and etc. the average output is supposed to be directly written to an excel sheet. this process is to be done for all the files in the folder.
the codes i used are the following:
to read multiple files
numfiles = 6;
mydata = cell(1,numfiles);
for k = 1:numfiles
myfilename = dlmread(sprintf('test%d.xlsx',k));
mydata{k} = importdata(myfilename);
end
to compute
T.message=categorical(T.message);
B = T(T.message=='18FF0803x',:);
columns = B(:,7:end);
%accessing the first column
engine_temperature = columns{:,1};
engine_temperature = hex2dec(engine_temperature);
engine_temperature(:,1) = 1*engine_temperature(:,1) – 40;
mean_engine_temperature = mean(engine_temperature);
%accessing the second column
engine_oil_pressure = columns{:,2};
engine_oil_pressure = hex2dec(engine_oil_pressure);
engine_oil_pressure(:,1) = 0.02*engine_oil_pressure(:,1);
mean_engine_pressure = mean(engine_oil_pressure);
to write the output to the excel sheet
writecell(mean_engine_temperature,filename,'Sheet','Temperatures','Range','B');
can anyone please help me to put this code in a loop such that all the files are opened and decoded one after the other and the mean temperature and pressure values are printed in consequent rows and columns.
Best Answer