write a function that converts a seconds input and returns the number of days, hours, mins, and seconds as outputs in matlab

main.m
function [days, hours, mins, seconds] = convertSeconds(totalSeconds)
    % Calculate days
    days = floor(totalSeconds / (24 * 3600));
    
    % Calculate remaining seconds after days
    remainingSeconds = totalSeconds - days * 24 * 3600;
    
    % Calculate hours
    hours = floor(remainingSeconds / 3600);
    
    % Calculate remaining seconds after hours
    remainingSeconds = remainingSeconds - hours * 3600;
    
    % Calculate minutes
    mins = floor(remainingSeconds / 60);
    
    % Calculate remaining seconds after minutes
    seconds = remainingSeconds - mins * 60;
end
591 chars
20 lines

gistlibby LogSnag