Technique to create nested structures, MATLAB in Engineering

Technique to create Nested structures:

This technique is the most proficient. Though, the other technique is to build the nested structure one field at a time. As this is a nested structure with one structure inside of the other, the dot operator should be used twice here to get to the real x- and y-coordinates.

 

>> lineseg.endpoint1.x = 2;

>> lineseg.endpoint1.y = 4;

>> lineseg.endpoint2.x = 1;

>> lineseg.endpoint2.y = 6;

 

The nested structure has been once created; we can refer to various parts of the variable lineseg. Just typing the name of the variable represents only that it is a structure having two fields, endpoint1 and endpoint2, each of which is a structure.

>> lineseg

lineseg =

  endpoint1: [1x1 struct]

  endpoint2: [1x1 struct]

 

Typing the name of the nested structures will show the field names and the values within that structure:

>> lineseg.endpoint1

ans =

  x: 2

  y: 4

 

By using the dot operator twice will refer to a separate coordinate, for illustration,

>> lineseg.endpoint1.x

ans =

    2

Posted Date: 10/20/2012 6:08:27 AM | Location : United States







Related Discussions:- Technique to create nested structures, Assignment Help, Ask Question on Technique to create nested structures, Get Answer, Expert's Help, Technique to create nested structures Discussions

Write discussion on Technique to create nested structures
Your posts are moderated
Related Questions
Sort algorithm for Sorting vectors of structures: Note that only the price field is compared in the sort algorithm, but the whole structure is replaced. That is therefore each

Example of Gauss-jordan: For a 2×2 system, this would results and for a 3 × 3 system, Note that the resulting diagonal form does not involve the right-most col

Function iscellstr - string function: The function iscellstr will return the logical true when a cell array is a cell array of all the strings, or logical false if not. >>

Simplification Functions: There are numerous functions which work with expressions, and simplify the terms. Not all the expressions can be simplified, but the simplify functio

Creating a cell array: The other method of creating a cell array is easy to assign values to particular array elements and build it up element by element. Though, as explained

Inverse of square matrix: The inverse is, hence the result of multiplying the scalar 1/D by each and every element in the preceding matrix. Note that this is not the matrix A,

Comparing strings: There are few functions which compare strings and return logical true when they are equivalent or logical false when not. The function strcmp compares the s

Gauss-Jordan: The Gauss-Jordan elimination technique begins in similar way which the Gauss elimination technique does, but then rather than of back-substitution, the eliminati

Image Processing: The Images are represented as grids, or matrices, of picture elements (known as pixels). In MATLAB an image usually is represented as a matrix in which each

Use of While loop: Here is an illustration of calling the function, passing 5000 for the value of the input argument high. >> factgthigh(5000) ans = 5040 The itera