Illustration of initializing the data structure, MATLAB in Engineering

Illustration of initializing the data structure:

illustration of initializing the data structure by preallocating is here as shown:

>> cyls(3) = struct('code', 'c', 'dimensions',.  .  .

  struct('rad', 3, 'height', 6), 'weight', 9);

>> cyls(1) = struct('code', 'x', 'dimensions',.  .  .

  struct('rad', 3, 'height', 6), 'weight', 7);

>> cyls(2) = struct('code', 'a', 'dimensions',.  .  .

  struct('rad', 4, 'height', 2), 'weight', 5);

Alternatively, it could be initialized by using the dot operator:

>> cyls(3).code = 'c';

>> cyls(3).dimensions.rad = 3;

>> cyls(3).dimensions.height = 6;

>> cyls(3).weight = 9;

>> cyls(1).code = 'x';

>> cyls(1).dimensions.rad = 3;

>> cyls(1).dimensions.height = 6;

>> cyls(1).weight = 7;

>> cyls(2).code = 'a';

>> cyls(2).dimensions.rad = 4;

>> cyls(2).dimensions.height = 2;

>> cyls(2).weight = 5;

Posted Date: 10/20/2012 6:12:21 AM | Location : United States







Related Discussions:- Illustration of initializing the data structure, Assignment Help, Ask Question on Illustration of initializing the data structure, Get Answer, Expert's Help, Illustration of initializing the data structure Discussions

Write discussion on Illustration of initializing the data structure
Your posts are moderated
Related Questions
Execution steps: Whenever the program is executed, the steps below will take place: The script calcandprintarea starts executing. The calcandprintarea calls the readr

Built-in colormaps: The MATLAB has numerous built-in colormaps which are named; the reference page on colormap shows them. Calling the function colormap without passing any ar

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,


Algorithm for the function explaine: The algorithm for the function explaine is as shown:  Print a description of e, the exp function, and how to find the approximate va

Print from the structure: To print from the structure, a disp function will show either the whole structure or a field. >> disp(package) item_no: 123 cost: 19.99

Replacing a string - function strrep: The function strrep finds all the occurrences of a substring within the string, and substitutes them with a new substring. The order of a

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

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

IS Functions in Matlab: There are many functions which are built into MATLAB which test whether or not something is true; these function names start with the word is. As these