MATLAB Answers

Translated by

このページのコンテンツは英語から自動翻訳されています。自動翻訳をオフにする場合は「<a class="turn_off_mt" href="#">ここ</a>」をクリックしてください。

0

what is difference in cell and structure plz tell me with example

manoj saini さんによって質問されました 2012 年 12 月 15 日
what is difference in cell and structure plz tell me with example

  0 件のコメント

サインイン to comment.

タグ

2 件の回答

回答者: Image Analyst
2012 年 12 月 15 日
 採用された回答

Matt gave a good explanation. I'd just like to add a few things. With a cell array, you refer to a cell with a number (the index), with a structure you refer to a "member" with its name. For example ca{1} = 'Hello manoj' while myStruct.myString = 'Hello manoj'. You see, the number 1 for the cell index, and "myString" for the structure member (or "field") name.
A cell in a cell array is referred to with parentheses, while the contents of the cell are referred to with braces. For example ca(1) would be a cell and that cell might have a string in it, while ca{1} would be the contents of ca(1) which would be the actual string itself, say, 'Hello manoj'.
There is also a function called celldisp() to display the cell contents.

  1 件のコメント

thanks very much

サインイン to comment.


回答者: Loginatorist
2012 年 12 月 15 日
編集済み: Loginatorist
2012 年 12 月 15 日

There is good documentation on this, did you read:
doc cell
doc struct
Here is a cell array:
C{1} = magic(3);
C{2} = 'A character array!';
C{3} = 3
Here is a structure:
S.color = 'red';
S.length = 5;
S.matrix = eye(4)
Now look at how you get information out of both of these:
C{2} % Displays the contents of cell 2 of cell array C
S.matrix % Shows contents of field 'matrix' of struct S.

  1 件のコメント

thanks sir

サインイン to comment.



Translated by