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!