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

94 Ansichten (letzte 30 Tage)
manoj saini am 15 Dez. 2012
Beantwortet: anas am 27 Nov. 2023
what is difference in cell and structure plz tell me with example
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Akzeptierte Antwort

Image Analyst am 15 Dez. 2012
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 Kommentar-1 ältere Kommentare anzeigen-1 ältere Kommentare ausblenden
manoj saini am 17 Dez. 2012
thanks very much

Melden Sie sich an, um zu kommentieren.

### Weitere Antworten (2)

Matt Fig am 15 Dez. 2012
Bearbeitet: Matt Fig am 15 Dez. 2012
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 Kommentar-1 ältere Kommentare anzeigen-1 ältere Kommentare ausblenden
manoj saini am 17 Dez. 2012
thanks sir

Melden Sie sich an, um zu kommentieren.

anas am 27 Nov. 2023
The following equation describes the motion of a certain mass connected to a spring, with viscous friction on the surface
3j + 39j + 120y = f(t)
where f(t) is an applied force. Suppose that f(t) = 0 for t < 0 and f(t) = 10 t >= 0
a. Plot y(t) for y(0)= dot y(0) = 0 .
b. Plot y(t) for y(0) = 0 and iv(0) = 10 Discuss the effect of the nonzero initial velocity.
Use the ode 45 Solver for this problem.
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Kategorien

Mehr zu Workspace Variables and MAT-Files finden Sie in Help Center und File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by