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 view (last 30 days)
Show older comments
MUKESH VIKRAM
on 23 Jun 2016
Commented: MUKESH VIKRAM
on 28 Jun 2016
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 Comments
Accepted Answer
Guillaume
on 23 Jun 2016
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);
More Answers (0)
See Also
Categories
Find more on Data Type Conversion in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!