Info

此问题已关闭。 请重新打开它进行编辑或回答。

How to sort a vector of filenames considering a conditions

1 次查看(过去 30 天)
gr_abs_cell=[];
gr_rel_cell=[];
projectdir = 'C:\Users\39338\Desktop\PROJECTMATLAB\TD_output';
info = dir( fullfile(projectdir, 'P*') );
info(~[info.isdir]) = [];
folder = fullfile(projectdir, {info.name});
folderdim = length(folder);
for ii=1:folderdim
foldinfo = dir( fullfile(folder{ii}, 'P*') );
foldinfo(~[foldinfo.isdir]) = [];
foldnames = fullfile(folder{ii}, {foldinfo.name});
numfold = length(foldnames);
for didx = 1 : numfold
thisfold = foldnames{didx};
dinfo = dir(fullfile(thisfold, 'P*.mat'));
filenames = fullfile(thisfold, {dinfo.name});
numfiles = length(filenames);
for fidx = 1 : numfiles
thisfile = filenames{fidx};
datastruct = load(thisfile);
A= datastruct.gr_abs;
gr_abs_cell=[gr_abs_cell;A];
B= datastruct.gr_rel;
gr_rel_cell=[gr_rel_cell;B];
end
end
end
[DATA, txt] = xlsread('Table_GR_TD_children.xlsx');
antro_matrix=[DATA(2:10,1:5); DATA(13:14,1:5); DATA(16:17,1:5); DATA(19:20,1:5);DATA(22:54,1:5);DATA(56,1:5);DATA(58:63,1:5)];
list_table=[txt(2:10,2); txt(13:14,2); txt(16:17,2); txt(19:20,2);txt(22:54,2);txt(56,2);txt(58:63,2)];
antro_matrix_cell = arrayfun(@num2str,antro_matrix,'UniformOutput',false); % link double to cell
gr_abs_cell = arrayfun(@num2str,gr_abs_cell,'UniformOutput',false);
gr_rel_cell = arrayfun(@num2str,gr_rel_cell,'UniformOutput',false);
C = [list_table,antro_matrix_cell];
antro = sortrows(C,1);
General_matrix = [antro,gr_abs_cell,gr_rel_cell];
This is my code.
C of Matlab is [:,A:F] of excel. I would like to sort C respecting the column J that is the info.name in matlab and so it is tha order of computation (I tried natsortfiles but it doesn't work).
The column H is to show you where is my problem if I compute antro.

回答(0 个)

此问题已关闭。

标签

Community Treasure Hunt

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

Start Hunting!

Translated by