Using "find" in cell inside cell with different data types

11 vues (au cours des 30 derniers jours)
Ekaterina Serikova
Ekaterina Serikova le 19 Sep 2017
Commenté : Guillaume le 20 Sep 2017
Hello,
my data is 1x253 cell, inside each are 253 further cell matrices with different sizes. An example of one of the cells is:
'COP PE Equity' NaN NaN 'COR PE Equity' NaN NaN NaN NaN
735452 6332 'NoValue' 633 '#N/A Invalid Security' NaN 'NoValue'0 NaN
735475 2232 'NoValue' 223 NaN NaN NaN NaN NaN
735545 304.1 'NoValue' 304.1 NaN NaN NaN NaN NaN
NaN NaN NaN NaN NaN NaN NaN NaN
NaN NaN NaN NaN NaN NaN NaN NaN
NaN NaN NaN NaN NaN NaN NaN NaN
NaN NaN NaN NaN NaN NaN NaN NaN
NaN NaN NaN NaN NaN NaN NaN NaN
NaN NaN NaN NaN NaN NaN NaN NaN
NaN NaN NaN NaN NaN NaN NaN NaN
I would like to implement the following:
for i=1:4:3497
if strcmp(data{1,a}{2,i},'#N/A Invalid Security') ==0 && strcmp(data{1,a}{2,i},'#N/A N/A') ==0 && strcmp(data{1,a}{2,i},'Date') ==0 && strcmp(data{1,a}{2,i},'TURNOVER') ==0
for j=1:size(date,1)
index = find(date(j,1)==data{1,a}(:,i));
if isempty(index)
final{1,a}(j,ceil(i/4)) = nan;
else
final{1,a}(j,ceil(i/4)) = data{1,a}{index,i+4};
end
end
end
end
So, I would like to go in each cell matrix inside cell "data", search for each element from "date" vector, and use the fourth column value for the orresponding row (index) in a new cell "final".
When I run this code, I get error message
"Function 'subsindex' is not defined for values of class 'cell'.".
When I try to use:
find(date(j,1)==cell2mat(data{a}(:,i))),
I get error
"Error using cell2mat (line 45) All contents of the input cell array must be of the same data type."
Could you please advise me on how to proceed?
Thanks a lot.
  6 commentaires
Walter Roberson
Walter Roberson le 20 Sep 2017
You can create cell arrays of tables.
Guillaume
Guillaume le 20 Sep 2017
... or you could have one table where each column is a cell array of column, depending on what's better for later processing.
A cell array of tables would be easier to generate but possibly harder to search.
Alternatively, you could have just one big table with an additional column indicating which file/cell array the data came from. This would make searching/filtering almost trivial.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by