Filter löschen
Filter löschen

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 Ansicht (letzte 30 Tage)
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 Kommentare
MUKESH VIKRAM
MUKESH VIKRAM am 1 Jul. 2016
Bearbeitet: Walter Roberson am 1 Jul. 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

Melden Sie sich an, um zu kommentieren.

Antworten (1)

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

Kategorien

Mehr zu File Operations finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by