Question: % % Structures ABCs % % Given Input Variables: % 1 . a _ time - A string of some time % 2 . a
Structures ABCs
Given Input Variables:
atime A string of some time
adate Some numerical date
btime A string of some time
bdate Some numerical date
st A structure with at least the field 'City'
st A structure with at least the fields 'State' and 'TimeZone'
f A string of a fieldname in the structure st
var An unknown value
A Creating structures manually. Create a structure with two fields:
'time' and 'date'. In the first field, 'time', store the value
contained in the variable atime". In the second field, 'date', store
the value contained in the variable adate". Do NOT use the
functions struct or setfield for this problem. Your final answer should
be stored in the variable A
A ;
Atime atime"
Adate adate"
DO NOT DELETE OR MODIFY THIS LINE AUTOGRADERCHECKA
B Creating structures using struct Create a structure with two
fields: 'time' and 'date'. In the first field, 'time', store the value
contained in the variable A ;
the value contained in the variable bdate". You MUST use the
function struct for this problem. Your final answer should
be stored in the variable B
B structtimebtime",date,"bdate";
C Accessing. What is the value of the field named 'State' in st You
may NOT use getfield for this problem. Your final answer should
be stored in the variable C
C stState;
D Accessing indirectly. The variable f will contain a string
representing a fieldname. What is the value of the field f in the
structure st You may NOT use getfield for this problem. Your
final answer should be stored in the variable D
D ;
E fieldnames Use the function fieldnames to create a cell array
containing a list of all the fields from st Your final answer should
be stored in the variable E
E ;
F rmfield Use the function rmfield to create a structure equal to
st with the field named 'TimeZone' removed. The original structure st
should not be changed. Your final answer should be stored in the variable A
F ;
G After running the following line of code, will the field named 'City'
exist within st If yes, the answer should yield the logical true,
and if no the answer should yield the logical value false. I
rmfieldst'City'
Important Note: This is not the same as st rmfieldst'City'
G ;
H isstruct Is the value of var a structure? You answer should be
either the logical true if var is a structure and false otherwise.
H ;
I. isfield Does st have a field named 'Major'? You answer should be
either the logical value true if st does have a field named 'Major'
and false otherwise.
I ;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
