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

I have a 400x2 vel.dat and 20x2 xy.dat file, how can i plot a streamslice graph on matlab with this two files.

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

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

Example to change the line width from the default: For illustration, to change the line width from the default of 0.5 to 1.5: >> set(hl,'LineWidth',1.5) As long as the

Finding a sting - function strfind: The function strfind does necessarily similar thing, except that the order of the arguments does make dissimilarity. The common form is str

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

Converting between the String and Number types: The MATLAB has many functions which convert numbers to strings in which each character element is a separate digit, and vice ve

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

Intersect function and setdiff function: The intersect function rather than returns all the values which can be found in both of the input argument vectors. >> intersect(v