technique is to create one element -


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

Request for Solution File

Ask an Expert for Answer!!
Applications of MATLAB: technique is to create one element -
Reference No:- TGS0175110

Expected delivery within 24 Hours