how to get the content of cell array

4 visualizaciones (últimos 30 días)
neamah al-naffakh
neamah al-naffakh el 9 de Mayo de 2017
Comentada: Jan el 10 de Mayo de 2017
I have an array called (dataBig2) that contains 20234 cells.
Each cell contains N number of rows and 9 columns (the first 7 columns are integer and the last 2 are 'string'). please see the attached image.
I'd like to obtain the content of each cell and store it .
for example, I have used this line of code to get the content of the first cell (i.e., 30*9) from dataBig2
x=dataBig2{1}(:,:);
by using the above line of code I was able to get the content of the first cell but I want to store the content of the remaining cells because I have 20234 cells inside the array Bigdata2
I hope that make sense!
thank you very much in advance!

Respuestas (2)

Matt J
Matt J el 9 de Mayo de 2017
Editada: Matt J el 9 de Mayo de 2017
I would probably split the contents into numeric and string parts
for i=1:size(dataBig2,2)
numpart(:,:,i)=cell2mat( dataBig2{i}(:,1:7) );
stringpart(:,:,i)= dataBig2{i}(:,8:9)
end
  2 comentarios
Matt J
Matt J el 9 de Mayo de 2017
Editada: Matt J el 9 de Mayo de 2017
Incidentally, if dataBig came from xlsread, you could have read the numeric data and text into separate arrays using the syntax,
[num,txt] = xlsread(___)
neamah al-naffakh
neamah al-naffakh el 9 de Mayo de 2017
no i have did some code to extract the data from two different files and then i mixed them! thanks

Iniciar sesión para comentar.


Jan
Jan el 9 de Mayo de 2017
Editada: Jan el 9 de Mayo de 2017
What do you want exactly? val{k} contains the contents of the first cell. It does not matter, if you copy the cell dataBig2 to the cell final, because this changes the name of the variable only.
Do you want to get the numerical values as matrices?
value = cell(1, numel(dazaBig2);
info = cell(1, numel(dazaBig2);
for k = 1:numel(dataBig2)
s = size(dataBig{k}, 2);
value{k} = cell2mat(dataBig2{k}(:, 1:s-2));
info{k} = dataBig2{k}(:, s-1:s);
end
The trailing columns containing strings cannot be included in the numerical matrices, but it is stored separately. I'm not sure if this is useful.
  3 comentarios
Matt J
Matt J el 9 de Mayo de 2017
Editada: Matt J el 9 de Mayo de 2017
I want to get the content of each cell array and store it!
But how is that different from what you already have? Each of the 20234 data sets is already "stored" in Bigdata2{i} and indexing operations Bigdata2{i}{j,k} are already available to let you "get" any particular cell inside that.
If you are saying that you want the data to be indexed differently, then describe what that indexing operation will look like.
Jan
Jan el 10 de Mayo de 2017
@neamah al-naffakh:
x = dataBig2{1}(:,:);
is the same as
x = dataBig2{1};
So what's wrong with using dataBig2{1} directly?

Iniciar sesión para comentar.

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