フィルターのクリア

How do i create the following cell array ?

1 回表示 (過去 30 日間)
Abbi Hashem
Abbi Hashem 2019 年 6 月 1 日
編集済み: Stephen23 2019 年 6 月 1 日
this is what I have in mind :
Capture.PNG
as you can see, the main matrix is 2*4, and within each cell there are 3 values
Question 1 :how do I create this ?
Question 2 if I want to access one of the cells( accessing all 3 values as a vector), corresponding to row r and column c , how can I do so ?
Quesiton 3 if I want to access the 2nd element of the 3rd top cells from the left ( here it would be 6 ), how can I do so ?

採用された回答

Stephen23
Stephen23 2019 年 6 月 1 日
編集済み: Stephen23 2019 年 6 月 1 日
Q1.
C = {[2,3,1],[1,5,6],[4,6,5],[3,1,7];[3,5,7],[2,4,6],[2,6,3],[8,2,3]}
Q2.
C{r,c} % access the cell contents (i.e. the numeric array)
C(r,c) % access the cell itself
Q3.
C{1,3}(2)
You should also read the MATLAB documentation:
  3 件のコメント
Stephen23
Stephen23 2019 年 6 月 1 日
編集済み: Stephen23 2019 年 6 月 1 日
"What if I wanted to build those dimensions initially , where all values are zeros ? "
Your question is not very clear, but I think you mean this:
C = repmat({[0,0,0]},2,4)
or
C = cell(2,4);
C(:) = {[0,0,0]}
Note that for container types (e.g. cell arrays) it is often not required to preallocated the contents of the cells (unless they might be changing size in a loop, or similar):
Abbi Hashem
Abbi Hashem 2019 年 6 月 1 日
yup exactly what I meant
Thank you so much !

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by