Q:

The built-in clock function returns a vector with six elements representing the year, month, day, hours, minutes and seconds. The first five elements are integers whereas the last is a double value, but calling it with fix will convert all to integers

0

 The built-in clock function returns a vector with six elements 

representing the year, month, day, hours, minutes and seconds. The 

first five elements are integers whereas the last is a double value, but 

calling it with fix will convert all to integers. The built-in date function 

returns the day, month, and year as a string. For example,

>> fix(clock)

ans =

2013 4 25 14 25 49

>> date

ans =

25-Apr-2013

Write a script that will call both of these built-in functions, and then 

compare results to make sure that the year is the same. The script will

have to convert one from a string to a number, or the other from a 

number to a string in order to compare.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Ch7Ex30.m

% Compares years obtained from built-in functions

% date and clock to ensure they are the same

c = fix(clock);

d = date;

dyear = str2double(d(end-3:end));

if dyear == c(1)

 disp('Years are the same!')

else

 disp('Years are not the same.')

end

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now