Technique to creating this structure, MATLAB in Engineering

Technique to creating this structure:

An alternative technique of creating this structure, that is not as efficient, includes using the dot operator to refer to fields in the structure. The name of structure variable is followed by dot, or a period, and then name of the field within that structure. The Assignment statements can be used to assign values to the fields.

>> package.item_no = 123;

>> package.cost = 19.99;

>> package.price = 39.95;

>> package.code = 'g';

 

By using the dot operator in the first assignment statement, the structure variable is generated with the field item_no. The later three assignment statements add more fields to the structure variable.

Adding a field to the structure later is accomplished as shown former, by using an assignment statement.

The whole structure variable can be assigned to the other. This would make sense, for illustration, if the two structures had some values in common. Here, for illustration, the values from one structure are copied into the other and then two fields are selectively changed.

 

>> newpack = package;

>> newpack.item_no = 111;

>> newpack.price = 34.95

newpack =

item_no: 111

cost: 19.9900

price: 34.9500

code: 'g'

 

Posted Date: 10/20/2012 5:56:24 AM | Location : United States







Related Discussions:- Technique to creating this structure, Assignment Help, Ask Question on Technique to creating this structure, Get Answer, Expert's Help, Technique to creating this structure Discussions

Write discussion on Technique to creating this structure
Your posts are moderated
Related Questions
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

Uses of Function handles: The Function handles can also be generated for functions other than anonymous functions, both built-in & user-defined functions. For illustration, th

str2num function - String: The function str2num does the opposite; it takes the string in which a number is stored and converts it to the type double: >> num = str2num('123.

Example of file ploting data: As the other example, a data file called 'compsales.dat' stores the sales figures (in millions) for divisions in a company. Each line in the f

Forward elimination: In forward elimination, we want to obtain a 0 in the a 21 position. To accomplish this, we can alter the second line in the matrix by subtracting from it

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

Cross Product: The cross or outer product a × b of two vectors a and b is defined only whenever both a and b are the vectors in three-dimensional space, that means that they b

Reading from a Mat-File: The load function is used to read from various types of files. As with save function, by default the file will be supposed to be a MAT-file, and load

A matlab function to calculate filter order

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. >>