Effacer les filtres
Effacer les filtres

dbhole.mat contains 334 files. each files consists of [2xn] data. i sort these files with name starting with 'd' and fixed 'h2'. if h2 is not fixed, then what will be the code for doing this?

1 vue (au cours des 30 derniers jours)
selectedvariables = sprintfc('d%dh2', 1:14);
[~, location] = ismember(selectedvariables, fieldnames(s));
c = struct2cell(s);
c = c(location);
if h2 is not fixed. i want to sort each 'd'followed by numeric and each 'h' followed by numeric
  4 commentaires
MUKESH VIKRAM
MUKESH VIKRAM le 1 Juil 2016
Modifié(e) : Walter Roberson le 1 Juil 2016
i had used another code , but i does not show exact result which i want.
for i=1:14
for j=1:16
data_2hole{i}=mat2cell(eval(['d',num2str(i),'h',num2str(j)]),length(eval(['d',num2str(i),'h',num2str(j)])));
data= (data_2hole{j,i}{1,1}')
end
end
please tell me how to run all the 'h' contained in each d

Connectez-vous pour commenter.

Réponses (1)

Thorsten
Thorsten le 30 Juin 2016
I would organise the data into a 2D cell data{}{} and work with this structure.
load dbhole.mat
W = whos('d*h*');
for i = 1:numel(W)
name = W(i).name;
idx = sscanf(name,'d%dh%d');
cmd = sprintf('data{%d}{%d} = %s;', idx(1), idx(2), name);
disp(cmd)
eval(cmd)
end
% plot the data
for i = 1:numel(data), plot(data{i}{1}), hold on, end

Catégories

En savoir plus sur File Operations dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by