フィルターのクリア

How do I use information in mat file?

1 回表示 (過去 30 日間)
Linjun He
Linjun He 2018 年 11 月 22 日
コメント済み: Linjun He 2018 年 12 月 19 日
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

採用された回答

Stephen23
Stephen23 2018 年 11 月 22 日
編集済み: Stephen23 2018 年 11 月 22 日
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:
  3 件のコメント
Stephen23
Stephen23 2018 年 11 月 22 日
Simpler:
parfor k = 1:10
F = sprintf('IDMOEAD/IDMOEAD_DSDTLZ1_M3_%d.mat',k);
S = load(F);
S.metric = NHV(S.Population.objs,S.PF);
save(F,'-struct','S');
end
Linjun He
Linjun He 2018 年 12 月 19 日
For unknow reason, you can not use save() in parfor directly.
That is why I created a "redundant" function parsave().

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeFile Operations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by