MatLab calculation