time = '10:00'; shift = {{'NY','+5:00'}}; numClocks = length(shift); for ndx = 1:numClocks [atlhr, minutes] = strtok(time, ':'); atlhr = str2num(atlhr); [hr, ~] = strtok(shift{ndx}{2}, ':'); hrshift = hr(1); hr = str2num(hr(2:end)); if hrshift == '+' hr = atlhr + hr; else hr = atlhr - hr; end if hr >= 12 hr = mod(hr, 12); end fprintf("%d%s\n",hr,minutes); end