Cell array containing cell arrays
6 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
dpb
2017 年 7 月 1 日
編集済み: dpb
2017 年 7 月 1 日
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
2017 年 7 月 7 日
編集済み: Stephen23
2017 年 7 月 7 日
@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.
回答 (2 件)
Walter Roberson
2017 年 7 月 1 日
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 件のコメント
dpb
2017 年 7 月 2 日
編集済み: dpb
2017 年 7 月 2 日
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
2017 年 7 月 2 日
編集済み: Image Analyst
2017 年 7 月 2 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!