필터 지우기
필터 지우기

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 (최근 30일)
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
MUKESH VIKRAM
MUKESH VIKRAM 2016년 7월 1일
편집: Walter Roberson 2016년 7월 1일
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

댓글을 달려면 로그인하십시오.

답변 (1개)

Thorsten
Thorsten 2016년 6월 30일
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

카테고리

Help CenterFile Exchange에서 File Operations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by