Cell array containing cell arrays

6 vues (au cours des 30 derniers jours)
mohamed abdinasir
mohamed abdinasir le 1 Juil 2017
Modifié(e) : Stephen23 le 7 Juil 2017
Hi there,
Im trying to extract particular information from each cell. I have 124 cells and in each cell contains 4 cells. I want to extract the pressure cells in each cell.
  4 commentaires
dpb
dpb le 1 Juil 2017
Modifié(e) : dpb le 1 Juil 2017
Pictures don't really help much in the details as we can't do anything with them but look and if it's not just trivial that generally isn't enough. Better would be to save one of these variables to .mat file and attach that.
Show the actual code that got those loaded; it's likely can get the complexity reduced and thus make the referencing simpler.
Even better would be to attach a (small) set of the initial data that created them to attack it from the beginning instead of trying to straighten it out from the other end...
Stephen23
Stephen23 le 7 Juil 2017
Modifié(e) : Stephen23 le 7 Juil 2017
@mohamed abdinasir: please edit your original question and:
  1. upload any files by clicking the paperclip button. Do not put huge amounts of code in a comment or question: it makes the thread unreadable.
  2. clearly explain what your question is, best would be to provide complete input and output examples as well.

Connectez-vous pour commenter.

Réponses (2)

Walter Roberson
Walter Roberson le 1 Juil 2017
cellfun( @(S) S.pressure, allstates, 'Uniform', 0 )
I did not put all of those into one array as we do not know that all of the pressure entries are the same size, and we do not know if you would want them arranged as rows or columns or just all put together into one large vector.
I speculate you might want
cell2mat( cellfun( @(S) S.pressure, allstates(:).', 'Uniform', 0 ) )
which would arrange them as columns.
  2 commentaires
mohamed abdinasir
mohamed abdinasir le 2 Juil 2017
what is the @(S) referring to. I've tried the code you've mentioned but says error in @(S)
dpb
dpb le 2 Juil 2017
Modifié(e) : dpb le 2 Juil 2017
It's the dummy argument to the anonymous function argument to cellfun
Look up anonymous functions for details
I'd reiterate the comments given earlier above about showing us how you got to this point and give us something real we can do something with besides looking at pictures.

Connectez-vous pour commenter.


Image Analyst
Image Analyst le 2 Juil 2017
Modifié(e) : Image Analyst le 2 Juil 2017
In one of the pictures I see "1-124" for the row index of allstates. That will give a value of -123 and you can't have the minus 123rd row of a matrix. Perhaps you meant 1:124, meaning rows 1 through 124.
  1 commentaire
Image Analyst
Image Analyst le 6 Juil 2017
So, did fixing the 1-124 thing prevent the error?

Connectez-vous pour commenter.

Catégories

En savoir plus sur Matrix Indexing 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