The MATLAB function dir returns the contents of a specified directory. It returns the result in the form of a structure array with four fields, for example,

s = dir

s =
123x1 struct array with fields:
name
date
bytes
isdir
datenum

size(s)

ans =
123     1

fieldnames(s)

ans =
'name'
'date'
'bytes'
'isdir'
'datenum'


Here in the above, the directory contains 123 objects. Write a MATLAB function that takes the path to a directory and outputs the total size of all files in the directory in units of bytes.

Here is an example implementation of getBytes.m.