How do I use information in mat file?
1 次查看(过去 30 天)
显示 更早的评论
Here's the information in each .mat file.(metric, PF, Population)
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.
Extension: I have many .mat files like this.How do I handle this in a batch?
0 个评论
采纳的回答
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
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
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Database Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!