Confusing questions on cells

1 回表示 (過去 30 日間)
RuiQi
RuiQi 2016 年 12 月 5 日
編集済み: per isakson 2016 年 12 月 5 日
I am studying cells in matlab and I have some questions that I find very confusing.
Question 1
temperature(1,:) = {'01-Jan-2010', [45, 49, 0]};
stuff = temperature(1,1) % stuff = cell
stuff = temperature{1,1} % stuff = content of cell {1,1} which is 01-Jan-2010
Therefore curved brackets pass me the cell and curly brackets pass me the contents of that cell. Why does
stuff = temperature(1,1:end) % stuff = temperature which is a cell
stuff = temperature{1,1:end} % why does it not give me the contents of both into stuff ? I only get stuff = 01-Jan-2010 why the array gone ?
Question 2
I have a 1 x 7 cell where each cell is a 10000 x 1 int. I can use cell2mat to get data
box = cell2mat(cell([1 3:7])); box is now a 10000 x 6 array
But why cant I
box = cell{[1 3:7]} % Box equals to the extracted stuffs (curly brackets) of column 1 and 3 to 7
Question 3
I have a cell of 1 x 7 where each cell contains 10000 elements. How do I convert it a cell of 10000 x 7 ?

回答 (1 件)

per isakson
per isakson 2016 年 12 月 5 日
編集済み: per isakson 2016 年 12 月 5 日
  1. cell{[1 3:7]} creates a Comma-Separated Lists, which cannot be assigned to a variable.
  2. temperature{1,1:end} - same story

カテゴリ

Help Center および File ExchangeData Type Identification についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by