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
Q.1: Consider the transmission of a sinusoid x(t) = cos(2f0t) through a channel a ected by multipath and Doppler. Let there be two paths, and assume the sinusoid is being sent fro

Data structures: The Data structures are variables which store more than one value. In order to made sense to store more than one value in a variable, the values must in some

readlenwid function: function call: [length, width] = readlenwid; function header: function [l,w] = readlenwid In the function call, not any argument is passed; henc

Gauss, Gauss-Jordan elimination: For 2 × 2 systems of equations, there are well-defined, easy solution techniques. Though, for the larger systems of equations, finding solutio

Function rmfield - structure: The function rmfield eliminates a field from the structure. It returns a new structure with field eliminated, but does not modify the original st

Function used in sound files: The MATLAB has numerous other functions which let you read and play sound or audio files. In the audio files, sampled data for each audio channel

Example of Gauss-jordan: For a 2×2 system, this would results and for a 3 × 3 system, Note that the resulting diagonal form does not involve the right-most col

Plotting File data: It is frequently essential to read data from a file and plot it. Generally, this entails knowing the format of the file. For illustration, let us suppose t

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

Initializing the data structure - Function: Function is shown as:   >> printcylvols(cyls) Cylinder x has a volume of 169.6 Cylinder a has a volume of 100.5