Technique is to create one element - vector, MATLAB in Engineering

Technique is to create one element - vector:

Technique is to create one element with the values from one structure, and use repmat to replicate it to the preferred size. Then, the remaining elements can be modified. The below generates one structure and then replicates this into a 1 × 3 matrix.

>> packages = repmat(struct('item_no',587,'cost',.  .  .

11.11, 'price',33.33,'code','w'), 1,3);

>> packages(2) = struct('item_no',456,'cost', 5.99,.  .  .

'price',49.99,'code','l');

>> packages(3) = struct('item_no',587,'cost',11.11,.  .  .

'price',33.33,'code','w');

 

Typing the name of the variable will show only the size of the structure vector and the names of the fields:

>> packages

packages =

1x3 struct array with fields:

item_no

cost

price

code

Posted Date: 10/20/2012 6:05:37 AM | Location : United States







Related Discussions:- Technique is to create one element - vector, Assignment Help, Ask Question on Technique is to create one element - vector, Get Answer, Expert's Help, Technique is to create one element - vector Discussions

Write discussion on Technique is to create one element - vector
Your posts are moderated
Related Questions
Help command: The help command is used with the script rectarea, the function readlenwid, and the major function printrectarea. To see the first comment in the subfunction, as

Finding a sting - function findstr: The function findstr receives two strings as input arguments. It finds all the occurrences of shorter string contained by the longer, and r

Square Matrices: If a matrix has similar number of rows and columns, for illustration, if m == n, the matrix is square matrix. The definitions which follow in this part apply

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

Use polyval to evaluate the derivative at xder. This will be the % slope of the tangent line, "a" (general form of a line: y = ax + b). % 4. Calculate the intercept, b, of t

Write a program to examine exponential function: We will write a program to examine the value of e and the exponential function. It will be a menu-driven. The menu options wil

Function issorted - set operations: The function issorted will return 1 for logical true when the argument is sorted in ascending order (minimum to maximum), or 0 for false wh

Patch function - graphics objects: The patch function is used to generate a patch graphics object, which is made from 2-dimensional polygons. The patch is defined by its verti

Polyhedron - graphics objects: The field polyhedron.vertices is a matrix in which each row presents (x,y,z) points. The field polyhedron.faces defines the faces: for illustrat

IS Functions for Strings: There are many functions for strings, that return logical true or false. The function isletter returns the logical true when the character is a lette