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!