function fieldnames - structure functionsthe


Function fieldnames - structure functions:

The function fieldnames will return the names of the fields which are contained in the structure variable.

>> pack_fields = fieldnames(package)

pack_fields =

'item_no'

'cost'

'price'

'code'

 

As the name of the fields is of different lengths, the function fieldnames returns a cell array with the names of the fields.

To refer to the elements the curly braces are used, as pack_fields is a cell array.

For illustration, we can refer to the length of one of the strings as shown below:

>> length(pack_fields{2})

ans =

4

Request for Solution File

Ask an Expert for Answer!!
Applications of MATLAB: function fieldnames - structure functionsthe
Reference No:- TGS0175108

Expected delivery within 24 Hours