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
Example of Interpolation and extrapolation: The MATLAB has a function to do this, known as polyfit. The function polyfit finds the coefficients of the polynomial of the partic

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,

Illustration of Preallocating a Vector: Illustration of calling the function: >> myveccumsum([5 9 4]) ans =     5  14  18 At the first time in the loop, outvec wil

Displaying expressions: The good-looking function will show such expressions by using exponents; for illustration, >> b = sym('x^2') b = x^2 >> pretty(b)

Individual structure variable: The individual structure variable for one software package may look like this: The name of the structure variable is a package; it has f

Forward substitution: The Forward substitution (done methodically by first getting a 0 in the a 21 place, and then a 31 , and lastly a 32 ): For the Gauss technique,

Replacing, Finding, and separating strings: There are numerous functions which find and replace the strings, or parts of strings, within the other strings and functions which

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

Execution steps: Whenever the program is executed, the steps below will take place: The script calcandprintarea starts executing. The calcandprintarea calls the readr

Algorithm for subfunction: The algorithm for subfunction askforn is as shown:  Prompt the user for the positive integer n.  Loop to print an error message and reprom