MATLAB: How to use information in mat file

.mat filecell array

Here's the information in each .mat file.(metric, PF, Population)
eachFile.png
What I want to do is to use information in .mat file as inputs (PF->PF, Population->PopObj), and store the output (Score->metric) for the following function.
function.png
Extension: I have many .mat files like this.How do I handle this in a batch?
matFile.png

Best Answer

D = 'path to folder where those files are saved';
S = dir(fullfile(D,'*.mat'));
N = natsortfiles({S.name}); % download from FEX
C = cell(1,numel(N));
for k = 1:numel(N)
T = load(fullfile(D,N{k}));
C{k} = NHV(T.Population,T.PF);
end
This imports all .mat files in the given folder, runs the function NHV on their contents, and stores the function outputs in the cell array C. To get the right file order you can download the function natsortfiles here:
See also: