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
Structures: The Structures are data structures which group together values which are logically related in what are known as the fields of structure. The benefit of structures

Interpolation and extrapolation: In most cases, it is desired to estimate values other than at the sampled data points. For illustration, we may want to estimate what the temp

printrectarea function: function call: printrectarea(length, width) function header: function printrectarea(len, wid)   In the function call, there are two argume

Application: Menu driven Modular Program Numerous longer, more involved programs which have interaction with the user are menu-driven, that means that the program prints a men

deblank function: The deblank function eliminates only trailing blanks from the string, not leading the blanks. The strtrim function will eliminate both the leading and traili

Matrix Multiplication: The Matrix multiplication does not mean multiplying term by term; and it is not an array operation. The Matrix multiplication has a very particular mean

Illustration of Vectors of structures: In this illustration, the packages are vector which has three elements. It is shown as a column vector. Each and every element is a stru

Logical scalar values: The MATLAB also has or and and operators which work element wise for the matrices: These operators will compare any of the two vectors or matric

Finding sums and products: A very general application of a for loop is to compute sums and products. For illustration, rather than of just printing the integers 1 through 5, w

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