file contains 1x14 cells. each cell consist of [1x1] cell which in turn consist of data[189x2 doubles]. i have fetch all the datas and keep it in a single cell of 1xn cell. please help me out , how to code this?
조회 수: 1 (최근 30일)
이전 댓글 표시
i have this attached data into 1X14 cells but after that i was unable to do. it. please help me.
for i=1:14
data_hole2{i}=mat2cell(eval(['d',num2str(i),'h',num2str(2)]), length(eval(['d',num2str(i),'h',num2str(2)])));
end
댓글 수: 0
채택된 답변
Guillaume
2016년 6월 23일
We keep saying on this forum not to use eval. I assume that you ignored that advice and generated all these matrices with eval, and now you're stuck trying to process them. That's exactly why we say not to use eval. It only causes problems in the long run.
Anyway, if you want to group all these variables in a cell array, read them as a structure with load (simply by providing a destination to load) and convert that structure to a cell array:
s = load('dbhole.mat');
c = struct2cell(s) %will put all the variables in the cell array
If you only want the d*h2 variables, and in numeric order:
s = load('dbhole.mat');
selectedvariables = sprintfc('d%dh2', 1:14);
[~, location] = ismember(selectedvariables, fieldnames(s));
c = struct2cell(s);
c = c(location);
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Type Conversion에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!