Cell array containing cell arrays
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
dpb
am 1 Jul. 2017
Bearbeitet: dpb
am 1 Jul. 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
am 7 Jul. 2017
Bearbeitet: Stephen23
am 7 Jul. 2017
@mohamed abdinasir: please edit your original question and:
- 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.
- clearly explain what your question is, best would be to provide complete input and output examples as well.
Antworten (2)
Walter Roberson
am 1 Jul. 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 Kommentare
dpb
am 2 Jul. 2017
Bearbeitet: dpb
am 2 Jul. 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.
Image Analyst
am 2 Jul. 2017
Bearbeitet: Image Analyst
am 2 Jul. 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 Kommentar
Siehe auch
Kategorien
Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!