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

Illustration of anonymous functions: Dissimilar functions stored in the M-files, when no argument is passed to an anonymous function, the parentheses should still be in the fu

Use of built-in colormaps: MATLAB has built-in colormaps, it is also possible to generate others by using combinations of any colors. For illustration, the following generates

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

I have a frequency response data. How do I convert that to state space? I am given a 6 row and 3 column data (steady state). How do i convert that to state space model?

Defined a variable in work space: The variables defined in the script will become a part of the workspace: >> clear >> who >> mysummfile    15 >> who

Plotting from a Function: The following function creates a Figure Window as shown in figure, which shows various types of plots for similar y vector. The vector is passed as a

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

Variable Scope: The scope of any of variable is the workspace in which it is valid. The workspace generated in the Command Window is known as the base workspace. As we know

Illustration of Variable scope: Running this function does not add any of variables to the workspace, as elaborated: >> clear >> who >> disp(mysum([5 9 1]))