{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

structFromCell - Notes there will be no nested cell arrays...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Sheet1 Page 1 % Problem Statment: % % Write a function named structFromCell that takes in a cell array and % returns a structure constructed from the cell array. The elements in % the odd indexes of the cell array should determine the field name and % the elements in the even indexes should be the values cooresponding to % the field (element) from the previous index. % % Cell Array Format: {'fieldname1', value1, 'fieldname2', value2, ...}
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ..} % % Notes: % - there will be no nested cell arrays within the cell array (ex. % {'fred',{'george'}}) % - you may *not* use the MATLAB built in function struct() % - you may assume that a value will be given for every field name % (i.e.) the length of the cell array will be even % function str = stuctFromCell(ca) str = for index = 1:2:length(ca) str = setfield(str,ca{index},ca{index+1}) end...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online