dbhole.mat contains 334 files and each file contains data of[2xn]. I want that how many 'h'(i.e h1,h2 etc) are in each 'd' (i.e d1,d2, etc)
1 次查看(过去 30 天)
显示 更早的评论
for example, for d1, it has total 20h(d1h1,d1h2...d1h20). how to index out all the'h'in d1,d2...d14
1 个评论
Walter Roberson
2016-7-1
Duplicates earlier http://www.mathworks.com/matlabcentral/answers/293159-dbhole-mat-contains-334-files-each-files-consists-of-2xn-data-i-sort-these-files-with-name-start . Please hold the discussion there in the original post.
回答(2 个)
Andrei Bobrov
2016-7-1
编辑:Andrei Bobrov
2016-7-1
clear
load dbhole
a = whos;
n0 = {a.name}';
x = regexp(n0,'\d*','match');
x = x(~cellfun(@isempty,x));
x = cat(1,x{:});
z = sortrows(str2double(x));
[aa,~,c] = unique(z(:,1));
out = [aa, accumarray(c,1)];
0 个评论
Stalin Samuel
2016-6-30
Below approach may solve your problem
load dbhole
nfile = struct2cell(whos)
ret = nfile(1,1:end)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!