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)
Mostrar comentarios más antiguos
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
Walter Roberson
el 1 de Jul. de 2016
Duplicated by later http://www.mathworks.com/matlabcentral/answers/293161-dbhole-mat-contains-334-files-and-each-file-contains-data-of-2xn-i-want-that-how-many-h-i-e-h1-h Please keep the discussion here in this earlier post.
MUKESH VIKRAM
el 1 de Jul. de 2016
Editada: Walter Roberson
el 1 de Jul. de 2016
Respuestas (1)
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
0 comentarios
Ver también
Categorías
Más información sobre Shifting and Sorting Matrices 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!