Need some help
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Hey guys,
I have some questions that might be relatively simple, but I am not sure how to get about this:
I have a cell array called "TestData", which is a 1x99 cell array. In each cell of TestData is another huge cell array (I'm talking dimensions 85,000x14). So, I have that huge cell array 99 times in the variable TestData. Hope that makes sense.
I have several issues.
1. For each cell (of the 99) of Test Data, there exists some meaningless information that I want to autonomously remove. For example, I would like to remove rows 1 and 2, and columns 9 and 10. How can I do this for each of the 99 subcells in Test Data without manually doing it?
2. I want to save column 1 for each of the 99 cells in TestData into a new variable. How can I avoid manually doing this?
3. I want to convert "TestData" (and all of its contents) from a cell type to a numeric type. How can I effectively do this? If I try something like cell2mat, it gives me an error because cell2mat does not support conversion of cell arrays that have structures or objects within them.
4. Finally, I would like to combine each of the 99 terms in TestData into a single, huge matrix. So, I want the data to be stacked, like so:
TestData(1): 85000x14 TestData(2): 85000x14 (this is combined with TestData(1) to form a new matrix of 170000x14 TestData(3): ... etc etc
I know I am asking for a lot, but I am stuck at this point and I am not really sure how to do the above.
0 comentarios
Respuestas (2)
Rick Rosson
el 1 de Abr. de 2012
Do you know how to write a for loop in MATLAB?
4 comentarios
Geoff
el 1 de Abr. de 2012
You said that you "keep getting errors here and there". You should post the code that you DO have so we can help you get it working.
Kye Taylor
el 1 de Abr. de 2012
One way to accomplish what I think you're trying to do in items (1) and (2) of your original question is the following:
% row indices to remove
rowIdx2Remove = [1,2];
colIdx2Remove = [9,10];
newC = cell(size(TestData));
for j = 1:length(TestData)
TestData{j}(rowIdx2Remove,:) = []; % remove those rows
TestData{j}(:,colIdx2Remove) = []; % remove those cols
newC{j} = TestData{j}(:,1); % save first column in new cell array
end
However, without more specifics, that may not be helpful. Can you clarify the following?
1.) What do you want to do first, remove rows and cols, or save the first column of each array. 2.) How do you want the first column of each array to be stored? The code above stores it as contents in a new cell array, but you could store them as columns of a new matrix, for instance.
3.) If you want to convert your testData to a numeric type, you'll need to decide on an organization. In particular, you will have to store the data as a three-dimensional numeric array. One organization would be a 85000-by-14-by-99 numeric array, for instance. Is that along the lines of what you you're looking for? Can you add any specifics here?
4.) If you really want a single huge matrix, then the way you're indexing (wanting TestData(1) to be a 85000-by-14) is a little confusing. In a single huge matrix, M, indexing with M(j) will identify only a scalar (1-by-1 number) for all j<=numel(M). Perhaps you really mean a cell? Also, can you clarify what you want in the 3 and 4th elements (I can't tell if the third element is the concatenation of TestData(2) and TestData(3) or a concatenation of TestData(1), TestData(2), and TestData(3)) ?
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!