Write a function that has no input arguments, but one output argument.
Inside the function the currently present second from the computer time should be extracted
into a variable second_now and rounded.
If second_now is a multiple of 3, the function should output ’TRUE’ and if not ’FALSE’.
Call that function from a main script 10 times with one second pause in between and see
whether roughly 3 times the result is ’TRUE’
i didnt understand how to start with the code im still a beginner
function result = checkMultipleOfThree()
secondNow = round(now*86400) - fix(now)*86400;
result = mod(secondNow, 3) == 0;
end
% Main script
trueCount = 0;
for i = 1:10
result = checkMultipleOfThree();
if result
trueCount = trueCount + 1;
end
disp(result);
pause(1);
end
disp(['True count: ', num2str(trueCount)]);
welcome to stackoverflow! i am curious, have you read the docs? afaik the parameter is optional.