Borrar filtros
Borrar filtros

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 visualización (últimos 30 días)
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 comentarios
MUKESH VIKRAM
MUKESH VIKRAM el 1 de Jul. de 2016
Editada: Walter Roberson el 1 de Jul. de 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

Iniciar sesión para comentar.

Respuestas (1)

Thorsten
Thorsten el 30 de Jun. de 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

Categorías

Más información sobre File Operations en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by