Creating a variable referencing specific cells from a cell variable with 30 structures?

4 ビュー (過去 30 日間)
JM
JM 2018 年 4 月 2 日
編集済み: Stephen23 2018 年 4 月 2 日
I have a variable that I converted to a cell. This variable is a 1x30 cell with 30 structures within it. (I had multiple levels) Each structure is a set of data (3000x20).
I want to create a new variable that contains that 3000th row, 1st column from each of those structures (3000,1).
I've tried X = Variable30Structures {:,1}{3000,1} However I get a message "matlab Expected one output from a curly brace or dot indexing expression, but there were 30"
I'm sure there is a simple way to do this, but I'm stuck as I've never tried this before.
Any help would be appreciated! Thank you
  1 件のコメント
Stephen23
Stephen23 2018 年 4 月 2 日
編集済み: Stephen23 2018 年 4 月 2 日
You write that "This variable is a 1x30 cell with 30 structures within it", but then your example does not refer to any structure field: is this an actual MATLAB structure, or are you using the word "structure" just to describe "some organization of data" ? If it really is a structure, what fieldname is required to access that data?
"I have a variable that I converted to a cell"
Why? What form did the data have beforehand?

サインインしてコメントする。

回答 (1 件)

Stephen23
Stephen23 2018 年 4 月 2 日
編集済み: Stephen23 2018 年 4 月 2 日
Assuming that by "structure" you really just mean "array", and C is your cell array, then this might work for you:
tmp = cat(3,C{:});
out = tmp(3000,1,:)
You should read these too, they explain why your attempt does not work:

カテゴリ

Help Center および File ExchangeStructures についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by