Borrar filtros
Borrar filtros

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 visualización (últimos 30 días)
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

Respuesta aceptada

Guillaume
Guillaume el 23 de Jun. de 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);

Más respuestas (0)

Categorías

Más información sobre Data Type Conversion en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by